diff --git a/web-app/app.py b/web-app/app.py new file mode 100644 index 0000000..9b82223 --- /dev/null +++ b/web-app/app.py @@ -0,0 +1,33 @@ +from fastapi.templating import Jinja2Templates +from fastapi.staticfiles import StaticFiles +from fastapi import FastAPI + +import yaml +import uvicorn + +from routes import home + +app = FastAPI() +config = yaml.safe_load(open('./config.yaml')) + +app.mount('/static/', StaticFiles(directory='./web/static/')) +app.mount('/node_modules', StaticFiles(directory='./web/node_modules/')) + +app.include_router(home.router) + + + +if __name__ == '__main__': + uvicorn.run( + app, + host=config['server']['host'], + port=5050, + ssl_keyfile= + config['server']['ssl_privkey'] + if config['server']['ssl_work'] + else None, + ssl_certfile= + config['server']['ssl_cert'] + if config['server']['ssl_work'] + else None + ) diff --git a/web-app/routes/home.py b/web-app/routes/home.py new file mode 100644 index 0000000..1f92f77 --- /dev/null +++ b/web-app/routes/home.py @@ -0,0 +1,9 @@ +from fastapi import APIRouter, Request +from starlette.responses import FileResponse, HTMLResponse + +router = APIRouter() + + +@router.get('/', response_class=HTMLResponse) +async def home(req: Request): + return FileResponse('./web/html/index.html')