35 lines
829 B
Python
35 lines
829 B
Python
from fastapi import FastAPI, Request, HTTPException
|
|
from fastapi.responses import JSONResponse
|
|
from routes import authR, userR
|
|
# from db import engine, models
|
|
# from sqlalchemy import event
|
|
# from db.seeds import initialize_table
|
|
import uvicorn
|
|
|
|
# event.listen(models.User.__table__, 'after_create', initialize_table)
|
|
|
|
app = FastAPI()
|
|
|
|
# models.Base.metadata.create_all(bind=engine)
|
|
|
|
@app.exception_handler(HTTPException)
|
|
async def unicorn_exception_handler(request: Request, exc: HTTPException):
|
|
return JSONResponse(
|
|
status_code=exc.status_code,
|
|
content={"status": exc.status_code, "data": exc.detail},
|
|
)
|
|
|
|
app.include_router(authR.authRouter)
|
|
app.include_router(userR.userRouter)
|
|
|
|
def main():
|
|
uvicorn.run(
|
|
"main:app",
|
|
port=8000,
|
|
host="0.0.0.0",
|
|
reload=True
|
|
)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|