App.run() does not serve a mounted ASGI app (routes=[Mount(...)]) that works with uvicorn.run(app)
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
The App.run() docstring in lib/streamlit/web/server/starlette/starlette_app.py is the entry point, and it claims to reuse the same ASGI runner as streamlit run. Start by comparing how App.run() and uvicorn.run(app) build the Starlette routes from the routes=[Mount(...)] argument. Reproduce with the two-file example (page.py and app.py), where /bokeh/app should render "Hello from Bokeh" under app.run() as it does under uvicorn. Done means the mounted route and its websocket work under both app.run() and streamlit run.
由索引模型根据 Issue 内容生成。
描述
Summary
Hi, I want to update my virtual observatory app (https://specsy.streamlit.app/) so that the user can download data selections from a Bokeh figure.
I have managed to get a working version by embedding a Bokeh server app (Bokeh 3.10 BokehASGI) in the Streamlit app via st.App(..., routes=[Mount("/bokeh", app=bokeh_app)]). When I serve the st.App with uvicorn.run(app), the mounted app works: the Bokeh page renders and its websocket callbacks run. When I start the same object with app.run(), the mounted route returns a blank white page.
Is mounting ASGI sub-applications via routes meant to be supported by App.run() and by streamlit run for st.App scripts? The App.run() docstring says it "reuses the same embedded ASGI server runner that streamlit run uses for st.App scripts".
The reason I am asking is that Streamlit Community Cloud launches apps with streamlit run, so I cannot use uvicorn.run(app) there. I would like a uniform Streamlit app for both the online and the offline installation.
Minimal reproducible example
page.py
import streamlit as st
st.write("Embedded Bokeh app below:")
st.iframe("/bokeh/app", height=300)
app.py
import sys
import streamlit as st
from starlette.routing import Mount
from bokeh.models import Div
from bokeh.server.asgi import BokehASGI
def bkapp(doc):
doc.add_root(Div(text="Hello from Bokeh"))
bokeh_app = BokehASGI({"/app": bkapp})
app = st.App("page.py", routes=[Mount("/bokeh", app=bokeh_app)])
if __name__ == "__main__":
if "--uvicorn" in sys.argv:
import uvicorn
uvicorn.run(app, host="localhost", port=8501) # works
else:
app.run() # mounted route is blank
Steps to reproduce
python app.py --uvicornand openhttp://localhost:8501/bokeh/app: "Hello from Bokeh" is shown, and the iframe in the Streamlit page also shows it.python app.pyand open the same URL: blank white page, and the iframe in the Streamlit page is empty.
Expected behaviour
app.run() serves the routes passed to st.App(routes=...), including mounted ASGI apps with websockets, the same way uvicorn.run(app) does. I'd expect the same behaviour with streamlit run app.py.
Additional information
- No errors in the terminal.
Environment
- Streamlit: 1.65.0
- Bokeh: 3.10.0
- Python: 3.13
- OS: Linux
- Browser: Firefox
Thanks a lot for any advice.
- 主要语言
- JavaScript
- 星标
- 178
- 派生
- 708
- 平均合并
- 1 天 21 小时
- 30 天内合并 PR
- 19
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
streamlit/docs 的其他 Issue
-
docs needs triage
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 2 天内回复
-
Fix description of Azure SQL support可能已有人在做 @Nikhil-jaiswal007 于 181 天前认领。 未关闭docs needs triage
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 2 天内回复
-
docs
难度 2/5 1-3 小时 新手友好度 62/100
streamlit/docs#719 · 2 条评论 · 1 个 reaction ·
维护者通常 2 天内回复
-
docs needs triage
难度 3/5 1-2 天 新手友好度 35/100
维护者通常 2 天内回复
-
bug needs triage
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 2 天内回复
相似的 Issue
-
data
难度 1/5 1 小时以内 新手友好度 74/100
gaseous-project/hasheous#637 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
gramps-project/gramps-web#1549 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
change request evaluating
难度 2/5 1-3 小时 新手友好度 72/100
sindresorhus/eslint-plugin-unicorn#3907 ·
维护者通常 1 天内回复
-
Priority: Low Production Type: Bug
难度 2/5 1-3 小时 新手友好度 68/100
GrottoCenter/grottocenter-api#1903 ·
维护者通常 1 天内回复