-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
42 lines (29 loc) · 886 Bytes
/
main.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
39
40
41
42
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from database.connection import Settings
from routes.users import user_router
from routes.moodevents import moodevent_router
app = FastAPI()
settings = Settings()
# register origins
origins = ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Register routes
app.include_router(user_router, prefix="/user")
app.include_router(moodevent_router, prefix="/moodevents")
@app.on_event("startup")
async def init_db():
await settings.initialize_database()
@app.get("/")
async def home():
return RedirectResponse(url="/moodevents/")
if __name__ == '__main__':
uvicorn.run("main:app", host="0.0.0.0", port=8080, reload=True)