fastapi server

# -*- coding: utf-8 -*-
# @时间 : 2020/3/15 4:09 下午
# @作者 : 陈祥安
# @文件名 : main.py.py
# @公众号: Python学习开发
# -*- coding: utf-8 -*-
# @时间 : 2020-03-11 18:35
# @作者 : 陈祥安
# @文件名 : main.py
# @公众号: Python学习开发
from fastapi import FastAPI

app = FastAPI()


# 先请求seed,参数,item_id等于1个数,v是值用uuid。
@app.get("/seed/")
async def read_item(item_id: int = 0, v: str = None):
    return {"seed_value": f"seed_{v}", "seed_item_id": f"seed_{item_id}"}


# 获取seed返回的值,存到队列
# 拿出来请求index获取的结果存队列
@app.get("/index/")
async def read_item(item_id: int = 0, v: str = None):
    return {"index_value": f"index_{v}", "index_item_id": f"index_{item_id}"}


# 请求detail

@app.get("/detail/")
async def read_item(item_id: int = 0, v: str = None):
    return {"detail_value": f"detail_{v}", "detail_item_id": f"detail_{item_id}"}

posted @ 2020-03-15 17:19  公众号python学习开发  阅读(288)  评论(0编辑  收藏  举报