-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (30 loc) · 949 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
import logging
import fastapi
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from rich.logging import RichHandler
from slowapi.errors import RateLimitExceeded
from Models.response import ExceptionResponse
from Routers.comic import comic_router
from Routers.user import user_router
from Services.Limiter.limiter import limiter
from Services.Modulator.manager import plugin_manager
logging.basicConfig(
level="INFO",
format="%(message)s",
datefmt="[%X]",
handlers=[RichHandler(rich_tracebacks=True, tracebacks_suppress=[fastapi])],
)
app = FastAPI()
app.state.limiter = limiter
app.add_exception_handler(RateLimitExceeded, ExceptionResponse.limit_exceeded)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
plugin_manager.load_plugins()
app.include_router(user_router)
app.include_router(comic_router)