forked from rusnyder/fastapi-plotly-dash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
34 lines (24 loc) · 874 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.wsgi import WSGIMiddleware
from dashapp import create_dash_app
app = FastAPI()
@app.get("/")
def read_main():
return {
"routes": [
{"method": "GET", "path": "/", "summary": "Landing"},
{"method": "GET", "path": "/status", "summary": "App status"},
{"method": "GET", "path": "/dash", "summary": "Sub-mounted Dash application"},
]
}
@app.get("/status")
def get_status():
return {"status": "ok"}
# A bit odd, but the only way I've been able to get prefixing of the Dash app
# to work is by allowing the Dash/Flask app to prefix itself, then mounting
# it to root
dash_app = create_dash_app(requests_pathname_prefix="/dash/")
app.mount("/dash", WSGIMiddleware(dash_app.server))
if __name__ == "__main__":
uvicorn.run(app, port=8000)