Fastapi: [QUESTION] How use pycharm debugger mode to develop my fastapi server

Created on 23 Nov 2019  ·  6Comments  ·  Source: tiangolo/fastapi

Like this, I can run my fastapi code! But I can't run it in debug mode for Pycharm IDE !
image

So, How use pycharm debugger mode to develop my fastapi server?

question

Most helpful comment

The easiest way is to just add a __main__ section to your app and run uvicorn by hand. Described here - https://fastapi.tiangolo.com/tutorial/debugging/

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)

All 6 comments

The easiest way is to make calls to your ASGI app using the starlette TestClient. You can see examples in the fastapi tests.

The easiest way is to just add a __main__ section to your app and run uvicorn by hand. Described here - https://fastapi.tiangolo.com/tutorial/debugging/

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)

Like this, I can run my fastapi code! But I can't run it in debug mode for Pycharm IDE !
image

So, How use pycharm debugger mode to develop my fastapi server?

Hi @HalfLeaf, I also encounter this problem. Have you solved it ?

Like this, I can run my fastapi code! But I can't run it in debug mode for Pycharm IDE !
image
So, How use pycharm debugger mode to develop my fastapi server?

Hi @HalfLeaf, I also encounter this problem. Have you solved it ?

I have sovled this problem. See: https://fastapi.tiangolo.com/tutorial/debugging/

 uvicorn.run(app,host = “ 0.0.0.0 ”,port = 8000)

yes, you are right,great, thank you!

Thanks for the help here everyone!

Thanks @HalfLeaf for reporting back and closing the issue :+1:

Was this page helpful?
0 / 5 - 0 ratings