首先安装依赖包:
接着在项目文件夹中创建文件 main.py,其中的代码为:
main.py
然后,你可以启动 fastapi 的接口了:(在终端中运行)
现在可以打开 postman 并使用 post 方式向 http://127.0.0.1:8000/items/ 接口发送以下字段:
postman
post
http://127.0.0.1:8000/items/
那么你将获得以下响应: