Skip to content

Attachments and Python objects

If you want to include static files like PDFs or Excel docs in your app, use the dp.Attachment block. You can also pass in a Python object directly. Once you upload the app, your users will be able to explore and download these attachments.

Simple attachment

import datapane as dp

data_path = "./netflix_stock_data.csv"

app = dp.App(dp.Attachment(file=data_path))

app.save(path="simple-attachment.html")

Python object attachment

import datapane as dp

vehicle_dict = {"brand": "Ford", "model": "Mustang", "year": 1964}

app = dp.App(dp.Attachment(vehicle_dict, name="vehicle_dict"))

app.save(path="object-attachment.html")

Multiple attachments

import datapane as dp

data_path = "./netflix_stock_data.csv"

vehicle_dict = {"brand": "Ford", "model": "Mustang", "year": 1964}

app = dp.App(
    dp.Attachment(file=data_path), dp.Attachment(vehicle_dict, name="vehicle_dict")
)

app.save(path="multiple-attachments.html")