from fastapi import FastAPI
from fastapi.responses import FileResponse
app = FastAPI()
#预制菜 static/index.html 提前写好页面直接进行返回了,速度快.
@app.get("/")
async def read_index():
print(f"访问静态文件目录")
return FileResponse("static/index.html")
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)