fastApi

官网:https://fastapi.tiangolo.com/zh/#_2

源码:https://github.com/fastapi/fastapi

 指定版本安装:

image

 入门案例:

from fastapi import FastAPI

app = FastAPI()

@app.get('/hello')
async def hello():
    return {"message": "Hello World"}

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

image

 启动方式二:命令启动(uvicorn filename:app_name --reload)

image

示例:uvicorn test:app --reload


其他启动方式:

 fastapi dev filename.py  (需要安装pip install "fastapi[standard]")

 

 
posted @ 2025-11-20 23:00  iTao0128  阅读(7)  评论(0)    收藏  举报