使用VS CODE 开发FastAPI时,launch.json如下配置,就可以使用VS CODE的“运行和调试”工具了。
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "python",
"stopOnEntry": false,
"request": "launch",
"module": "uvicorn",
"console": "internalConsole",
"args": [
"main:app",
"--reload",
"--port",
"18069"
],
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
}
],
"compounds": []
}