[New Feature] Rest API implementation to showcase the OpenDBM features

This commit is contained in:
Rudy Haryanto
2022-10-04 03:07:29 +07:00
parent a574bc6870
commit 92e08860a8
41 changed files with 2576 additions and 0 deletions

45
rest_api/app/main.py Normal file
View 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)