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

[HTTP/1.1 404 Not Found 28ms]
[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.