chore: filled in project structure

Added some example basic files containing a functioning /message
endpoint which logs the received message to INFO.

ref: N25B-144
This commit is contained in:
2025-10-08 15:02:11 +02:00
parent 9e96d57b6c
commit 1229df70b0
9 changed files with 100 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
# External imports
import contextlib
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import logging
# Internal imports
from control_backend.api.v1.router import api_router
from control_backend.core.config import settings
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
@contextlib.asynccontextmanager
async def lifespan(app: FastAPI):
logger.info("%s starting up.", app.title)
yield
logger.info("%s shutting down.", app.title)
# if __name__ == "__main__":
app = FastAPI(title=settings.app_title, lifespan=lifespan)
app.include_router(api_router, prefix="") # TODO: make prefix /api/v1
# This middleware allows other origins to communicate with us
app.add_middleware(
CORSMiddleware, # https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
allow_origins=[settings.ui_url.unicode_string()], # address of our UI application
allow_methods=["*"], # GET, POST, etc.
)
@app.get("/")
async def root():
return {"status": "ok"}