-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (26 loc) · 796 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 os
import uvicorn
from fastapi import FastAPI, Request
from fastapi.middleware.gzip import GZipMiddleware
from handler import handler_exception
from routes import routes
logger = logging.getLogger(__name__)
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - def %(funcName)s - %(message)s",
)
app = FastAPI()
app.add_middleware(GZipMiddleware, minimum_size=1000)
for route in routes:
app.include_router(route)
@app.exception_handler(Exception)
async def exception_handler(request: Request, exc: Exception):
return await handler_exception(request, exc)
if __name__ == "__main__":
uvicorn.run(
"main:app",
host="0.0.0.0",
port=int(os.environ.get("PORT", 5000)),
access_log=False,
)