Serve a prebuilt mkdocs site in iframe on streamlitcloud

I’ve a fully functional streamlit app when I’m running locally, but when I run it on streamlit-cloud it fails at the last hurdle.

I need to serve a folder of content as a website (before final deploy). I build the content with mkdocs and then run a subprocess for to serve the content (there may be a better way):

        p = subprocess.Popen("python -m http.server -d site 9001".split())
        st.session_state["server_pid"] = p.pid
        components.iframe("http://localhost:9001/", height=1200)

What I see on streamlit-cloud is “localhost refused to connect”, which is understandable.

Does anyone have a solution for this? Is there a native way to embed the pre-generated website?

Hey @keiranmraine,

If the content you’re serving is just pre-built static files, then you should be able to use the components.html method to embed them.

From what I can see from the docs that is only if you are presenting a single string representation of a page. I need to host a full static website.

Raised FR here: Widget to host folder as website (for preview) · Issue #6195 · streamlit/streamlit · GitHub

Hey @keiranmraine, just wanted to make sure you’ve seen our team’s recent response on that thread.

Hi @keiranmraine , FYI we recently added some limited static hosting which can be setup via config

Static file serving - Streamlit Docs

In general we wanted to be careful about exposing more ways to serve arbitrary html/js/css in Streamlit, so it won’t work for this use case (html files will render as plaintext). But depending on the feedback on the feature we will consider whether to expose it in the future.

Curious to know if this config/folder based approach makes sense for your use case or if it would need a component API like the one you proposed.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.