pip install fastapi[all]
pip install aiofiles
from fastapi import FastAPI, Request, requests
from fastapi.responses import JSONResponse, HTMLResponse
import uvicorn
from fastapi.staticfiles import StaticFiles
import asyncio
app = FastAPI()
app.mount("/static", StaticFiles(directory="./static"), name="static")
@app.route("/", methods=["GET", "POST"])
async def index(Request):
if Request.method == "GET":
return HTMLResponse("HELLO")
else:
return HTMLResponse("HELLO")
if __name__ == "__main__":
uvicorn.run(app='nlp:app', host="0.0.0.0", port=8000)
关注西北乱跑娃,了解更多干货!