-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
32 lines (24 loc) · 823 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
from fastapi import FastAPI
from fastapi import HTTPException
from fastapi import status
from fastapi.requests import Request
from fastapi.responses import JSONResponse
from router.users import user_router
from router.endpoint import blog_router
from db.db_api import engine
from db import models
from exceptions import CustomException
app = FastAPI()
app.include_router(blog_router)
app.include_router(user_router)
@app.get('/')
def index():
return "Welcome to FastAPI Application!"
@app.exception_handler(CustomException)
def custom_handler(request: Request, exc: HTTPException):
return JSONResponse(
exc.detail,
status_code=status.HTTP_418_IM_A_TEAPOT
)
models.Base.metadata.create_all(engine)
# uvicorm command `uvicorn file_name:object_name [options]`