The following are in a minimal working state: - Database schema - Basic database interaction - Configuration file parsing - Command line interface - Basic route handling for categories, auth and health - Simple static webapp files
38 lines
872 B
Python
38 lines
872 B
Python
from pathlib import Path
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from mft.settings import settings
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
app = FastAPI(
|
|
title=settings.app_name,
|
|
version=settings.version,
|
|
description="A simple expense tracking application",
|
|
)
|
|
|
|
# Configure CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Register routes
|
|
from mft.routes import api_router
|
|
|
|
app.include_router(api_router, prefix=settings.api_prefix)
|
|
|
|
static_dir = Path(__file__).parent / "static"
|
|
app.mount("/", StaticFiles(directory=static_dir, html=True), name="static")
|
|
|
|
return app
|
|
|
|
|
|
app = create_app()
|