go中redigo操作,获取多个数据

如何在windows中安装Docker Desktop 及排查安装问题

  返回  

Python FastAPI实现Flask的Blueprint类似功能

2021/7/20 18:34:38 浏览:

工程目录

app

... __init__.py .

.. users.py

main.py

from fastapi import APIRouter

router = APIRouter()

@router.get('/{id}')
async def users(id):
    return {'name':'Bob'+id}

路由注册

from fastapi import FastAPI
import uvicorn

from app.users import router as user_router

app=FastAPI()

app.include_router(user_router,prefix='/users')


if __name__=='__main__':
    uvicorn.run(app,host='127.0.0.1',port=8000)

调用测试 GET http://127.0.0.1:8000/users/23

HTTP/1.1 404 Not Found
date: Tue, 10 Jul 2021 10:25:39 GMT
server: uvicorn
content-length: 22
content-type: application/json
Connection: close

{
  "detail": "Not Found"
}

联系我们

如果您对我们的服务有兴趣,请及时和我们联系!

服务热线:18288888888
座机:18288888888
传真:
邮箱:888888@qq.com
地址:郑州市文化路红专路93号