mirror of
https://github.com/mihail911/modern-software-dev-assignments.git
synced 2026-10-02 03:54:37 +08:00
35 lines
864 B
Python
35 lines
864 B
Python
from pathlib import Path
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.responses import FileResponse
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from .db import apply_seed_if_needed, engine
|
|
from .models import Base
|
|
from .routers import action_items as action_items_router
|
|
from .routers import notes as notes_router
|
|
|
|
app = FastAPI(title="Modern Software Dev Starter (Week 5)")
|
|
|
|
# Ensure data dir exists
|
|
Path("data").mkdir(parents=True, exist_ok=True)
|
|
|
|
# Mount static frontend
|
|
app.mount("/static", StaticFiles(directory="frontend"), name="static")
|
|
|
|
|
|
@app.on_event("startup")
|
|
def startup_event() -> None:
|
|
Base.metadata.create_all(bind=engine)
|
|
apply_seed_if_needed()
|
|
|
|
|
|
@app.get("/")
|
|
async def root() -> FileResponse:
|
|
return FileResponse("frontend/index.html")
|
|
|
|
|
|
# Routers
|
|
app.include_router(notes_router.router)
|
|
app.include_router(action_items_router.router)
|