快速开始
环境要求
Python 3.8+
版本
安装模块
Phasellus posuere in sem ut cursus (1)
编写代码
在main.py
文件中,编写如下代码:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
然后在控制台启动项目
此时访问localhost:8000/
就能看到路由函数返回的 json 数据了。访问localhost:8000/docx
可以查看自动生成的 API 文档,并且支持测试。