# coding: utf8
from fastapi import FastAPI, BackgroundTasks
import time
import uvicorn
app = FastAPI()
def alter(email: str, msg = ""):
time.sleep(5)
print(email, msg)
@app.post('/send')
async def sendEmail(email: str, task: BackgroundTasks):
task.add_task(alter, email, msg='不关注')
return {"msg": '后台运行'}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)