1.安装uvicorn和FastAPI
pip3 install uvicorn
pip3 install FastAPI
2.python代码实现
import uvicorn
from fastapi import FastAPIapp = FastAPI()
@app.post("/ShowNum")
async def ShowNum(x:int=1,y:int=2):print('和为:%d' % (x+y))return x+yif __name__ == "__main__":uvicorn.run(app, host="0.0.0.0", port=8089)
如图所示已启动http端口监听
3.postman调用接口