Files
banban/mini-program/app/main.py
2026-03-25 15:58:48 +08:00

36 lines
814 B
Python

import os
from fastapi import FastAPI
try:
# For module mode: `uvicorn app.main:app`
from app.routers.health import router as health_router
from app.settings import settings
except ModuleNotFoundError:
# For script mode: `python app/main.py` or VS Code "Run Python File"
from routers.health import router as health_router
from settings import settings
def create_app() -> FastAPI:
app = FastAPI(
title=settings.app_name,
version=settings.app_version,
description=settings.app_description,
)
app.include_router(health_router)
return app
app = create_app()
if __name__ == "__main__":
import uvicorn
uvicorn.run(
app,
host=os.getenv("HOST", settings.host),
port=int(os.getenv("PORT", str(settings.port))),
)