Static file serving

Jeamlit apps can host and serve small, static media files to support media embedding use cases that won't work with the normal media elements.

In Standalone mode, Media stored in the folder ./static/ relative to the running app file is served at path app/static/[filename], such as http://localhost:8080/app/static/cat.png.

In Embedded mode, it is the folder ./static/ relative to the resources folder that is served.

  • Files with the following extensions will be served normally:
    • Common image types: .jpg, .jpeg, .png, .gif
    • Common font types: .otf, .ttf, .woff, .woff2
    • Other types: .pdf, .xml, .json
  • Jeamlit sets X-Content-Type-Options:nosniff for all files rendered from the static directory.
  • Jeamlit sets Cache-Control: max-age=3600 for all files. This means static files are cached 1 hour by the browser. If you edit a static file, empty your browser cache to get the newest version.
  • Put an image cat.png in the folder ./static/
  • Any media in the ./static/ folder is served at the relative URL like app/static/cat.png
import io.jeamlit.core.Jt; public class StaticExample { public static void main(String[] args) { Jt.title("A cat").use(); Jt.markdown("![a cat](/app/static/cat.png)").use(); } }
forum

Still have questions?

Go to our discussions forum for helpful information and advice from Jeamlit experts.