33 lines
699 B
Python
33 lines
699 B
Python
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
from settings import settings
|
|
from api import router
|
|
from utils import billing_manager
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""应用生命周期管理"""
|
|
await billing_manager.start()
|
|
yield
|
|
await billing_manager.shutdown()
|
|
|
|
|
|
app = FastAPI(
|
|
title="Pattern to Tshirt",
|
|
description="将图片中的花型添加到T恤上",
|
|
version="1.0.0",
|
|
lifespan=lifespan
|
|
)
|
|
|
|
# 注册路由
|
|
app.include_router(router)
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(
|
|
"app:app",
|
|
host=settings.host,
|
|
port=settings.port,
|
|
reload=settings.debug
|
|
) |