diff --git a/1.18.0/static-file-serving/.streamlit/config.toml b/1.18.0/static-file-serving/.streamlit/config.toml new file mode 100644 index 0000000..bf2516f --- /dev/null +++ b/1.18.0/static-file-serving/.streamlit/config.toml @@ -0,0 +1,2 @@ +[server] +enableStaticServing = true \ No newline at end of file diff --git a/1.18.0/static-file-serving/requirements.txt b/1.18.0/static-file-serving/requirements.txt new file mode 100644 index 0000000..737afbb --- /dev/null +++ b/1.18.0/static-file-serving/requirements.txt @@ -0,0 +1 @@ +streamlit==1.18.0 \ No newline at end of file diff --git a/1.18.0/static-file-serving/static/cat.jpg b/1.18.0/static-file-serving/static/cat.jpg new file mode 100644 index 0000000..ffb2520 Binary files /dev/null and b/1.18.0/static-file-serving/static/cat.jpg differ diff --git a/1.18.0/static-file-serving/static/dog.jpg b/1.18.0/static-file-serving/static/dog.jpg new file mode 100644 index 0000000..9176d8e Binary files /dev/null and b/1.18.0/static-file-serving/static/dog.jpg differ diff --git a/1.18.0/static-file-serving/streamlit_app.py b/1.18.0/static-file-serving/streamlit_app.py new file mode 100644 index 0000000..5cf009d --- /dev/null +++ b/1.18.0/static-file-serving/streamlit_app.py @@ -0,0 +1,49 @@ +import numpy as np +import pandas as pd +import streamlit as st + +st.write( + f'🐱', + unsafe_allow_html=True, +) + +""" +# Static file serving +""" + +st.caption("[Code for this demo]()") + +""" +Streamlit 1.18 allows you to serve small, static media files via URL. + +## Instructions + +- Create a folder `static` in your app's root directory. +- Place your files in the `static` folder. +- Add the following to your `config.toml` file: + +```toml +[server] +enableStaticServing = true +``` + +You can then access the files on `/app/static/`. Read more in our +[docs](). + +## Examples + +You can use this feature with `st.markdown` to put a link on an image: +""" + +with st.echo(): + st.markdown("[![Click me](app/static/cat.jpg)](https://streamlit.io)") + +""" +Or you can use images in HTML or SVG: +""" + +with st.echo(): + st.markdown( + '', + unsafe_allow_html=True, + )