首页 > 其他分享 >FastAPI - Get

FastAPI - Get

时间:2023-03-07 22:05:08浏览次数:29  
标签:__ return get FastAPI app Get def

from fastapi import FastAPI

import uvicorn


app = FastAPI()


# 默认接口文档 http://127.0.0.1:8000/docs

@app.get("/")

def index():

    '''这是首页'''

    return "this is a fast api"


@app.get("/user")

def user():

    '''这是获取所有用户'''

    return {"msg: get all users, code:200"}


@app.get("/projects")

def projects():

    return ["project1","project2"]


if __name__ == "__main__":

    uvicorn.run(app)








标签:__,return,get,FastAPI,app,Get,def
From: https://blog.51cto.com/u_12391275/6106469

相关文章