-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.py
33 lines (22 loc) · 881 Bytes
/
root.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
from fastapi import FastAPI, Request
import uvicorn
from database.connection import Settings
from routes import routelist
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
settings=Settings()
app=FastAPI()
app.mount("/static",StaticFiles(directory="static",html=True),name="static")
templates=Jinja2Templates(directory="templates/")
@app.on_event("startup")
async def init_db():
await settings.initialize_database()
@app.get("/")
def root(request:Request)-> dict:
return templates.TemplateResponse("base.html",
{
"request":request
})
app.include_router(routelist.todo_router,prefix="/todo")
if __name__ == "__main__":
uvicorn.run("root:app", host="0.0.0.0", port=8080,reload=True)