-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (34 loc) · 1.2 KB
/
Copy pathapp.py
File metadata and controls
38 lines (34 loc) · 1.2 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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from routes import badges, contests, docs, heatmap, legacy, profile, rating, stats, summary, topics
from config import Config
from core.middleware import CacheRateLimitMiddleware
app = FastAPI(
title=Config.TITLE,
description=Config.DESCRIPTION,
version=Config.VERSION,
)
app.add_middleware(
CORSMiddleware,
allow_origins=Config.CORS_ALLOW_ORIGINS,
allow_credentials=Config.CORS_ALLOW_CREDENTIALS,
allow_methods=Config.CORS_ALLOW_METHODS,
allow_headers=Config.CORS_ALLOW_HEADERS,
)
app.add_middleware(CacheRateLimitMiddleware, platform="codeforces")
app.include_router(docs.router)
app.include_router(profile.router)
app.include_router(stats.router)
app.include_router(contests.router)
app.include_router(rating.router)
app.include_router(heatmap.router)
app.include_router(topics.router)
app.include_router(badges.router)
app.include_router(summary.router)
app.include_router(legacy.router)
if __name__ == '__main__':
uvicorn.run("app:app",
host=Config.get_host(),
port=Config.get_port(),
reload=Config.RELOAD if Config.is_dev() else False)