Program/mooc/main.py
?..濡.. 8451ad034c 1.统一CRUD操作
2.完成登录部分接口
3.暂时挂载本地图片链接作为头像存储
2025-03-04 20:36:52 +08:00

27 lines
749 B
Python

from fastapi import FastAPI
from fastapi.exceptions import RequestValidationError
from starlette.exceptions import HTTPException
from mooc.core.exceptions import (
validation_exception_handler,
http_exception_handler,
generic_exception_handler
)
# 应用的其他代码...
def create_app() -> FastAPI:
app = FastAPI(
title=settings.PROJECT_NAME,
version=settings.VERSION,
# 其他设置...
)
# 注册异常处理器
app.add_exception_handler(RequestValidationError, validation_exception_handler)
app.add_exception_handler(HTTPException, http_exception_handler)
app.add_exception_handler(Exception, generic_exception_handler)
# 应用的其他设置...
return app