【Python】简单实现Http网络请求功能
1.安装uvicorn和FastAPI
pip3 install uvicorn
pip3 install FastAPI

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

3.postman调用接口



浙公网安备 33010602011771号