-
Notifications
You must be signed in to change notification settings - Fork 0
/
webapp.py
38 lines (24 loc) · 840 Bytes
/
webapp.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
35
36
37
38
from pathlib import Path
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from views import http_router, ws_router
app = FastAPI()
@app.get('/')
async def index():
return FileResponse('static/index.html')
@app.get('/robots.txt')
async def robots():
return FileResponse('static/robots.txt')
@app.get("/health")
async def get_health():
return {"status": "ok"}
app.include_router(http_router)
app.include_router(ws_router)
# Mount local static for HTML
app.mount('/static', StaticFiles(directory='static', html=True), name='static')
# Mount remote if present or local static for CSS
if Path('/extra').exists():
app.mount('/css', StaticFiles(directory='/extra'), name='css')
else:
app.mount('/css', StaticFiles(directory='static'), name='css')