Files
intelligent-daily-report-sy…/main.py
2026-02-25 15:22:23 +08:00

24 lines
799 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from fastapi import FastAPI
from fastapi.middleware.gzip import GZipMiddleware
from handler.exception import install as exception_install
from lifespan import lifespan
from plugin import CORSMiddleware, Monitor, PluginManager, Profiler
from utils.start import start
app: FastAPI = start(lambda: FastAPI(lifespan=lifespan))
# 添加 GZip 中间件
app.add_middleware(
GZipMiddleware,
minimum_size=1000, # 仅压缩大于 1000 字节的响应
compresslevel=5, # 压缩级别,范围为 1-9默认值为 9
)
# 安装异常处理中间件
exception_install(app)
# 安装需要启动后才能安装插件
plugin_manager = PluginManager(app)
plugin_manager.register_plugin(CORSMiddleware(app))
plugin_manager.register_plugin(Monitor(app))
plugin_manager.register_plugin(Profiler(app))