[New Feature] Rest API implementation to showcase the OpenDBM features
This commit is contained in:
45
rest_api/app/main.py
Normal file
45
rest_api/app/main.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import uvicorn
|
||||
from utils.app_exceptions import AppExceptionCase
|
||||
from fastapi import FastAPI
|
||||
from routers import router
|
||||
from config.database import create_tables
|
||||
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from starlette.exceptions import HTTPException as StarletteHTTPException
|
||||
|
||||
from utils.request_exceptions import (
|
||||
http_exception_handler,
|
||||
request_validation_exception_handler,
|
||||
)
|
||||
from utils.app_exceptions import app_exception_handler
|
||||
|
||||
create_tables()
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.exception_handler(StarletteHTTPException)
|
||||
async def custom_http_exception_handler(request, e):
|
||||
return await http_exception_handler(request, e)
|
||||
|
||||
|
||||
@app.exception_handler(RequestValidationError)
|
||||
async def custom_validation_exception_handler(request, e):
|
||||
return await request_validation_exception_handler(request, e)
|
||||
|
||||
|
||||
@app.exception_handler(AppExceptionCase)
|
||||
async def custom_app_exception_handler(request, e):
|
||||
return await app_exception_handler(request, e)
|
||||
|
||||
app.include_router(router.auth_router)
|
||||
app.include_router(router.router)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "Hello World"}
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||
Reference in New Issue
Block a user