发现个利器--FastAPI(Py3.6+版本)
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
return {"item_id": item_id, "q": q}
这么方便就算了,然后打开http://127.0.0.1:8000/docs,能看到接口信息!超便捷!
GitHub地址:https://github.com/tiangolo/fastapi