generated from admin/template
podex-api completed with swagger & docker compose
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from starlette.exceptions import HTTPException as StarletteHTTPException
|
||||
|
||||
from . import models
|
||||
from .database import Base, engine, SessionLocal
|
||||
from .errors import (
|
||||
AppError,
|
||||
app_error_handler,
|
||||
http_exception_handler,
|
||||
unhandled_exception_handler,
|
||||
validation_exception_handler,
|
||||
)
|
||||
from .loader import load_all
|
||||
from .routers import pokemons
|
||||
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
with SessionLocal() as _db:
|
||||
load_all(_db)
|
||||
|
||||
app = FastAPI(
|
||||
title="Pokédex API",
|
||||
version="1.0.0",
|
||||
docs_url="/docs",
|
||||
redoc_url="/redoc",
|
||||
openapi_url="/openapi.json",
|
||||
)
|
||||
|
||||
app.add_exception_handler(AppError, app_error_handler)
|
||||
app.add_exception_handler(StarletteHTTPException, http_exception_handler)
|
||||
app.add_exception_handler(RequestValidationError, validation_exception_handler)
|
||||
app.add_exception_handler(Exception, unhandled_exception_handler)
|
||||
|
||||
app.include_router(pokemons.router)
|
||||
Reference in New Issue
Block a user