尝试合并,所有代码需要调整from后文件路径。
This commit is contained in:
+8
-7
@@ -1,9 +1,11 @@
|
||||
from fastapi import FastAPI
|
||||
from students.api.students_api import students_api
|
||||
from fastapi import FastAPI,APIRouter
|
||||
from students.api.students_api import s_api
|
||||
from students.databases import *
|
||||
from students.model import students_model
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
Students_API = APIRouter()
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
Base.metadata.create_all(engine1)
|
||||
@@ -12,14 +14,13 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
app = FastAPI(title="学生管理系统",lifespan=lifespan) # 这里必须把上面写的加上
|
||||
|
||||
app.include_router(students_api,tags=["students"])
|
||||
|
||||
|
||||
def main():
|
||||
print("Hello from student-manage-system!")
|
||||
app.include_router(s_api,tags=["students"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
print("Hello from student-manage-system!")
|
||||
|
||||
import uvicorn
|
||||
uvicorn.run("main:app", host="0.0.0.0", port=51000)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user