-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (45 loc) · 1.31 KB
/
main.py
File metadata and controls
52 lines (45 loc) · 1.31 KB
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
43
44
45
46
47
48
49
50
51
52
from api.routes.app import app
from fastapi.middleware.cors import CORSMiddleware
from api.routes import (
usersRouter,
divisionsRouter,
rolesRouter,
assignmentsRouter,
announcementsRouter,
meetingsRouter,
submissionsRouter,
excusesRouter,
feedbacksRouter,
)
# set title and version for swagger
app.title = "Student Activity Platform API"
app.version = "0.0.1"
# include routers (link all of them to the main app)
app.include_router(usersRouter)
app.include_router(divisionsRouter)
app.include_router(rolesRouter)
app.include_router(assignmentsRouter)
app.include_router(announcementsRouter)
app.include_router(meetingsRouter)
app.include_router(submissionsRouter)
app.include_router(excusesRouter)
app.include_router(feedbacksRouter)
# set CORS policy
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
if __name__ == "__main__":
import uvicorn
import sys
# for deployment only (change localhost to 0.0.0.0)
host = "localhost"
reload = True
if len(sys.argv) > 1 and sys.argv[1] == "deploy":
host = "0.0.0.0"
reload = False
# run the service on the specified host and port (reload for development)
uvicorn.run("main:app", reload=reload, host=host, port=8000)