-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.py
35 lines (27 loc) · 862 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
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware
from starlette.responses import FileResponse
from starlette.staticfiles import StaticFiles
from domain.answer import answer_router
from domain.question import question_router
from domain.user import user_router
app = FastAPI()
origins = [
"http://127.0.0.1:5173", # Svelte
"http://localhost:3000", # React
"http://localhost:8000", # React
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(question_router.router)
app.include_router(answer_router.router)
app.include_router(user_router.router)
app.mount("/assets", StaticFiles(directory="frontend/dist/assets"))
@app.get("/")
def index():
return FileResponse("frontend/dist/index.html")