- Added user authentication and registration endpoints with JWT support. - Created tag management routes for creating and deleting tags. - Implemented value-added service (VAS) endpoints for managing storage packs and orders. - Developed WebDAV account management routes for creating, updating, and deleting accounts. - Introduced slave router for handling file uploads, downloads, and aria2 task management. - Enhanced JWT utility functions for token creation and secret key management. - Established lifespan management for FastAPI application startup and shutdown processes. - Integrated password handling utilities with Argon2 hashing and two-factor authentication support.
38 lines
964 B
Python
38 lines
964 B
Python
from fastapi import FastAPI
|
|
|
|
from utils.conf import appmeta
|
|
from utils.lifespan import lifespan
|
|
from models.database import init_db
|
|
from models.migration import migration
|
|
from utils.JWT import JWT
|
|
from routers import routers
|
|
|
|
# 添加初始化数据库启动项
|
|
lifespan.add_startup(init_db)
|
|
lifespan.add_startup(migration)
|
|
lifespan.add_startup(JWT.load_secret_key)
|
|
|
|
# 创建应用实例并设置元数据
|
|
app = FastAPI(
|
|
title=appmeta.APP_NAME,
|
|
summary=appmeta.summary,
|
|
description=appmeta.description,
|
|
version=appmeta.BackendVersion,
|
|
openapi_tags=appmeta.tags_meta,
|
|
license_info=appmeta.license_info,
|
|
lifespan=lifespan.lifespan,
|
|
debug=appmeta.debug,
|
|
)
|
|
|
|
# 挂载路由
|
|
for router in routers.Router:
|
|
app.include_router(router, prefix='/api')
|
|
|
|
# 启动时打印欢迎信息
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
if appmeta.debug:
|
|
uvicorn.run(app='main:app', reload=True)
|
|
else:
|
|
uvicorn.run(app=app) |