You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
597 B
27 lines
597 B
from fastapi import FastAPI
|
|
from app.api import Server, ShortCircuit
|
|
from app.api.ShortCircuit import app_start
|
|
|
|
|
|
def register_blueprints(app):
|
|
'''
|
|
registration route (module)
|
|
'''
|
|
# app.include_router(Server.router, tags=["API接口"])
|
|
app.include_router(ShortCircuit.router, tags=["电池短路API接口"])
|
|
|
|
async def lifespan(app):
|
|
# 应用启动时执行
|
|
await app_start()
|
|
|
|
# 在应用关闭时执行的代码
|
|
yield # 等待应用关闭
|
|
|
|
def create_app():
|
|
app = FastAPI(lifespan=lifespan)
|
|
|
|
#注册路由
|
|
register_blueprints(app)
|
|
|
|
return app
|