Direkt aus dem Tutorial ziehen: https://fastapi.tiangolo.com/tutorial/debugging/
Code: Select all
import uvicorn
from fastapi import FastAPI
app = FastAPI() # breakpoint here works on launching file
print('here') # breakpoint here works on launching file
@app.get("/")
def root():
a = "a" # breakpoint here does NOT work
b = "b" + a
return {"hello world": b} # returns data successfully
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=5002)
Ich bin mir nicht sicher, ob dies einen Unterschied macht, aber dies läuft auch über die Remote-SSH-Erweiterung auf VSCode (mein Code befindet sich auf einer gcloud-VM). Vielleicht trägt das dazu bei, aber auch die anderen Haltepunkte funktionieren einwandfrei.
Mein launch.json:
Code: Select all
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
Mobile version