Can't import local css and local jss in streamlit.v1.components.html

Hai, this is awsome library.
Iā€™ve an issue. I want to insert html which load local css and local js to my streamlit app. When I run my html independently, itā€™s work. But when I insert html string in streamlit.v1.components.html the local css and local js canā€™t be loaded. There are error in inspect console

GET http://192.168.99.59:8501/style.css
[HTTP/1.1 404 Not Found 28ms]
GET http://192.168.99.59:8501/js/app.js
[HTTP/1.1 404 Not Found 30ms]

Hello @Khanifudin_Al_Khasan, welcome to the community!

If you try to reference local CSS and JS files from your HTML and expose it through Streamlit, my guess is Streamlitā€™s server is configured to look for local files from the static folder of its install folder and not from the root of your project (see my answer here for more info)

So youā€™ll either need to move your CSS/JS to the static folder, or host them on a CDN/S3/Github public repo to reference them online.

Let me know if this works :slight_smile: as I havenā€™t actually tested my theory

Happy Streamlitinā€™
Fanilo :balloon:

1 Like

Thanks @andfanilo
Itā€™s work for css, but there is error in my .js

Uncaught TypeError: navigator.mediaDevices is undefined

while itā€™s fine when I run independently.