with one click
streamlit-starlette
// Guidelines and patterns for integrating Streamlit with Starlette and FastAPI using the unified ASGI architecture.
// Guidelines and patterns for integrating Streamlit with Starlette and FastAPI using the unified ASGI architecture.
| name | streamlit-starlette |
| description | Guidelines and patterns for integrating Streamlit with Starlette and FastAPI using the unified ASGI architecture. |
This skill provides instructions and code patterns for using the streamlit.starlette.App wrapper, organized by architectural concern.
This defines how the application is structured. The primary decision is: Who is the parent?
Use when the dashboard is the main product and the API is a supporting feature.
Reference: examples/mount_fastapi.py
Use when FastAPI is the main product and the dashboard is a visualization add-on.
Reference: examples/mount_streamlit_as_subapp.py
Use when you need simple endpoints without FastAPI overhead (no OpenAPI docs).
Reference: examples/route_custom_endpoints.py
Use when you need to host a folder as a website or serve JS/CSS assets.
Reference: examples/mount_static_files.py
Use when integrating with an existing Django project.
Reference: examples/mount_django.py
Use when integrating with an existing Flask app (requires a2wsgi).
Reference: examples/mount_flask.py
This defines how requests are intercepted and processed before they reach the Streamlit UI.
Add security headers (CSP, X-Frame-Options, HSTS) to all responses.
Reference: examples/middleware_security_headers.py
Block access if user is not authenticated (cookie check).
Reference: examples/middleware_auth.py
Set and read cookies via middleware.
Reference: examples/middleware_cookies.py
Restrict access to specific IP addresses.
Reference: examples/middleware_ip_whitelist.py
This defines how the API layer and the UI layer share data, and how metadata is served.
Pre-load resources (ML models, DB pools) on startup and clean up on shutdown. Includes cache pre-warming.
Reference: examples/core_lifespan_lifecycle.py
Expose endpoints as MCP tools for AI agents (requires fastmcp).
Reference: examples/route_mcp_server.py
Serve robots.txt, sitemap.xml, and manifest.json for SEO and PWA support.
Reference: examples/route_seo_metadata.py
async to avoid blocking the event loop."dashboard.py") are relative to the entry point file.