What is the local root directory used by streamlit? If I want to host local media, is there a directory I can put the files in?
Dinesh
What is the local root directory used by streamlit? If I want to host local media, is there a directory I can put the files in?
Dinesh
The root directory seems to be where the streamlit main file is. It doesn’t seem to be looking at the environment variable PYTHONPATH which was strange to me. It means that in order to import modules from your project, you have to put the streamlit main script in the root of your project regardless of the PYTHONPATH. That goes for local media as well, everything starts from the folder where the main script is.
Thanks @Alon. I didn’t ask my question well. I knew the info you’re saying.
However, if I use “img src=a.jpg” from a local directory, I cannot make a.jpg image displayed. The web server seems to be looking for the image in a different place. Thats the location I’m looking for.
Dinesh
Why not use st.image('a.jpg')
if the file is in the current root folder?
Various reasons related to how I want to place the image and text adjacent to it. @ash2shukla gave me a nice solution as the one recommended using native streamlit such as using st.beta_columns() didn’t work well for me. While @ash2shukla’s solution fixed the problem for me, I’m still curious to find the answer to what is the root directory for the webserver streamlit uses.
Best wishes,
Dinesh
Hey @ddutt,
The images are not hosted as it is, they are transformed and then hosted. So you can never actually get the original file over a static serve I think. The file directory where images are picked from is the same as your streamlit script directory but the name is changed to a sha224 hash of transformed content. Refer these to understand more,
The url would look something like this,
http://localhost:8501/media/de398b1efa63fc9f2d174278cf9e796c9a25fe03e8e1d4a5577c5dd9.jpeg
Hope it helps !
Maybe someone from streamlit devs can correct me if I am wrong @tim ?
Very cool, thanks once again @ash2shukla.
So it looks like your trick of using the base64 and the markdown is the best approach. I think that is worthy of a FAQ entry. Don’t you?
Best wishes,
Dinesh
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.