Skip to content

Instantly share code, notes, and snippets.

@tconkling
Last active December 21, 2022 14:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tconkling/1e5ead87c796a82de7fa71fcc4a74777 to your computer and use it in GitHub Desktop.
Save tconkling/1e5ead87c796a82de7fa71fcc4a74777 to your computer and use it in GitHub Desktop.
Serve static files from your Streamlit app
"""
Edit `streamlit/lib/Server.py`, and add "static_path" to `TORNADO_SETTINGS`.
You'll also need to import the `os` package.
See https://www.tornadoweb.org/en/branch5.1/guide/running.html#static-files-and-aggressive-file-caching
for more details.
"""
import os
TORNADO_SETTINGS = {
"compress_response": True, # Gzip HTTP responses.
"websocket_ping_interval": 20, # Ping every 20s to keep WS alive.
"websocket_ping_timeout": 30, # Pings should be responded to within 30s.
"websocket_max_message_size": MESSAGE_SIZE_LIMIT, # Up the WS size limit.
# Serve static files from <cwd>/static. To expose "myfile.txt" to the user
# for downloading, write it to static/myfile.txt, and then link to
# https://<yourserver>:8501/static/myfile.txt. (Or whatever port your
# streamlit server is running on.)
"static_path": os.path.join(os.getcwd(), "static"),
}
@vijaysaimutyala
Copy link

Once I add this change, it worked for a while and then streamlit app goes blank. Not sure whats exactly happening !!!

@nhchyy
Copy link

nhchyy commented Mar 5, 2020

wonderful,it works as wish, thanks

@nhchyy
Copy link

nhchyy commented Mar 5, 2020

i am at windows,the path is ----streamlit\server\Server.py

@nhchyy
Copy link

nhchyy commented Mar 17, 2020

Once I add this change, it worked for a while and then streamlit app goes blank. Not sure whats exactly happening !!!

also this problem i met

@vijaysaimutyala
Copy link

@nhchyy This hack is not dependable. It works on and off. Refer to this [link] (streamlit/streamlit#400 (comment))

@hind-hb
Copy link

hind-hb commented Apr 26, 2022

plz help me how to install streamlit

@nicolasesnis
Copy link

This is great, thanks for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment