1
0
mirror of https://github.com/ijaric/voice_assistant.git synced 2025-05-24 14:33:26 +00:00
voice_assistant/src/fastapi/lib/app/app.py
2023-09-19 09:53:33 +01:00

41 lines
1.2 KiB
Python

import logging
import logging.config as logging_config
import fastapi
import lib.api.handlers as admin_api_handlers
from .logger import LOGGING
from .settings import get_settings
logging_config.dictConfig(LOGGING)
logger = logging.getLogger(__name__)
class Application:
def __init__(self) -> None:
self.settings = get_settings()
self.logger = logging.getLogger(__name__)
self.producer = None
def create_app(self) -> fastapi.FastAPI:
app = fastapi.FastAPI(
title="FastAPI",
version="0.1.0",
docs_url="/api/openapi",
openapi_url="/api/openapi.json",
default_response_class=fastapi.responses.ORJSONResponse,
)
# app.include_router(admin_api_handlers.user_router, prefix="/api/v1/users", tags=["users"])
# app.include_router(admin_api_handlers.movie_router, prefix="/api/v1/movies", tags=["movies"])
@app.on_event("startup")
async def startup_event():
self.logger.info("Starting server")
@app.on_event("shutdown")
async def shutdown_event():
self.logger.info("Shutting down server")
return app