-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (32 loc) · 897 Bytes
/
Copy pathmain.py
File metadata and controls
44 lines (32 loc) · 897 Bytes
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
from fastapi import FastAPI, status
from fastapi.middleware.cors import CORSMiddleware
from starlette.responses import RedirectResponse
from api import router
from database.session import Base, engine
tags_metadata = [
{
'name': 'problems',
'description': 'List information of problems',
},
{
'name': 'submissions',
'description': 'List submissions of problems',
},
]
app = FastAPI(openapi_tags=tags_metadata, title='Judge')
origins = [
'http://localhost',
'http://localhost:8000',
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=['*'],
allow_headers=['*'],
)
@app.get('/', include_in_schema=False)
async def root():
return RedirectResponse(url='/docs', status_code=status.HTTP_302_FOUND)
app.include_router(router)
Base.metadata.create_all(bind=engine)