Frontend basics
This commit is contained in:
parent
8565ce19fe
commit
e310930d9e
10 changed files with 607 additions and 58 deletions
21
app/main.py
21
app/main.py
|
|
@ -2,6 +2,7 @@ import logging
|
|||
|
||||
from fastapi import FastAPI
|
||||
from injectable import load_injection_container
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from app.config import get_settings
|
||||
from app.core.core import WebhookProcessor
|
||||
|
|
@ -12,15 +13,15 @@ class KarlApplication:
|
|||
from starlette.types import Receive, Scope, Send
|
||||
def __init__(self) -> None:
|
||||
self._set_logging()
|
||||
_app = FastAPI(title="Karl", version="0.1.0")
|
||||
self._set_routes(_app)
|
||||
self._set_events(_app)
|
||||
_instance = FastAPI(title="Karl", version="0.1.0")
|
||||
self._set_routes(_instance)
|
||||
self._set_events(_instance)
|
||||
self._init_services()
|
||||
|
||||
self._app = _app
|
||||
self._instance = _instance
|
||||
|
||||
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
||||
await self._app.__call__(scope, receive, send)
|
||||
await self._instance.__call__(scope, receive, send)
|
||||
|
||||
def _set_logging(self):
|
||||
logging.basicConfig(level=logging.INFO, handlers=[LoggingHandler()])
|
||||
|
|
@ -39,14 +40,14 @@ class KarlApplication:
|
|||
logging_logger.handlers = [external_handler]
|
||||
logging_logger.propagate = False
|
||||
|
||||
def _set_routes(self, app: FastAPI):
|
||||
def _set_routes(self, instance: FastAPI):
|
||||
from app.core.router import router as core_router
|
||||
app.include_router(core_router)
|
||||
instance.include_router(core_router)
|
||||
from app.api.v1 import router as api_v1_router
|
||||
app.include_router(api_v1_router, prefix="/api/v1", tags=["v1"])
|
||||
pass
|
||||
instance.include_router(api_v1_router, prefix="/api/v1", tags=["v1"])
|
||||
instance.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||||
|
||||
def _set_events(self, app: FastAPI):
|
||||
def _set_events(self, instance: FastAPI):
|
||||
pass
|
||||
|
||||
def _init_services(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue