2024-11-19 11:28:05 +00:00
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
|
|
2024-11-20 08:25:36 +00:00
|
|
|
from fastapi import FastAPI
|
2024-11-18 11:47:19 +00:00
|
|
|
|
2024-11-19 12:08:21 +00:00
|
|
|
from api import login_reg, manage_project, manage_tanant, manage_user
|
2024-11-20 08:25:36 +00:00
|
|
|
from database import create_db_and_tables
|
2024-11-18 11:47:19 +00:00
|
|
|
|
|
|
|
|
# 用于生成和验证JWT的密钥
|
|
|
|
|
SECRET_KEY = "your_secret_key"
|
|
|
|
|
ALGORITHM = "HS256"
|
|
|
|
|
|
|
|
|
|
|
2024-11-19 11:28:05 +00:00
|
|
|
# @app.on_event("startup")
|
|
|
|
|
# def on_startup():
|
|
|
|
|
# create_db_and_tables()
|
|
|
|
|
@asynccontextmanager
|
|
|
|
|
async def lifespan(app: FastAPI):
|
|
|
|
|
create_db_and_tables()
|
|
|
|
|
yield
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = FastAPI(lifespan=lifespan)
|
2024-11-19 12:08:21 +00:00
|
|
|
app.include_router(login_reg.router)
|
|
|
|
|
app.include_router(manage_tanant.router)
|
|
|
|
|
app.include_router(manage_user.router)
|
|
|
|
|
app.include_router(manage_project.router)
|