How to Easily Debug a FastAPI App in VSCode

Поділитися
Вставка
  • Опубліковано 9 лют 2025

КОМЕНТАРІ • 46

  • @ArjanCodes
    @ArjanCodes  Місяць тому

    💡 Learn how to design great software in 7 steps: arjan.codes/designguide.

  • @chrisgeishauser
    @chrisgeishauser Місяць тому +3

    Not only a great tutorial about debugging FastAPI, but about debugging in general! I learned a lot, thanks!

  • @maviecestbon
    @maviecestbon Місяць тому +3

    I usually use the debug terminal instead of watch statements. The expressions I want to watch are usually to complex to fit into the watch section so setting a breakpoint and running the statement in the debug terminal is shorter.
    In general having access to a complete python REPL in the debug terminal is such a powerful feature :)

  • @tedlazar
    @tedlazar Місяць тому

    Happy New Year dear Arjan, with many great videos like 2024 !!!

  • @conneyk
    @conneyk Місяць тому

    Very helpful as always! Thank you Arjan

  • @jschwindt
    @jschwindt Місяць тому +1

    I also find very useful to use the debug console. After I reaching a breakpoint you can try expressions or inspect/call object methods directly in the debug console.

  • @demolazer
    @demolazer Місяць тому +1

    Perfect timing, how did you know? Literally doing this right now.

  • @magnus9999
    @magnus9999 Місяць тому

    After I have found the breakpoint() function it's been wonderful to stop the code and try different things to understand some unusual behaviour. But This video has great tips for debugger. Thanks.

  • @rangabharath4253
    @rangabharath4253 Місяць тому +1

    Awesome as always 🙂

  • @Necas209
    @Necas209 Місяць тому +18

    Just a heads up: you should probably disable automatic title translation for both regular videos and shorts. This video, for example, shows up as “01 03 DEBUG FASTAPI” on my country (Portugal). The same has been happening to your shorts. This title is mostly gibberish and sounds like a placeholder for the actual title English speakers must be seeing.

    • @Daviid_5
      @Daviid_5 Місяць тому +1

      01 03 2025 DEPURACIÓN FASTAPI in Spanish

    • @tjanos88
      @tjanos88 Місяць тому

      Yes, please.

    • @ArjanCodes
      @ArjanCodes  Місяць тому +7

      Thanks for pointing that out! UA-cam has done quite a few changes lately related to languages. We’ll look into it.

    • @mfeyx
      @mfeyx 29 днів тому

      On mobile the audio gets automatically translated as well (German, in my case), really annoying.

  • @ChaseAdams-s7o
    @ChaseAdams-s7o Місяць тому

    So excited for this video! THANK YOU! Watching now

  • @souravbanerjee309
    @souravbanerjee309 Місяць тому +7

    Please make a playlist about what to do and not to do in production-grade API building.

    • @baz_sh
      @baz_sh 21 день тому

      DO: authentication; error handling; scalability; security; DON'T: Ignore previous.

  • @jaivenkatesh1647
    @jaivenkatesh1647 Місяць тому

    Iam looking for this video all over youtube thanks for this video

  • @tswdev
    @tswdev Місяць тому

    Conditional breakpoints are super useful. I use them in Pycharm a lot. I didnt know about all those extra breakpoint types though, I dont think Pycharm has them. The break only on x number of hits, or "wait for other breakpoint" functionality.
    Seems really useful.

  • @difegam3
    @difegam3 Місяць тому

    Happy New Year / gelukkig nieuwjaar 🎉 and thank you for the great video! I would like to suggest the VS Code extension REST Client. It’s great for sending GET/POST requests and presenting the qry and response in a clear format.

  • @sanyahmed5960
    @sanyahmed5960 Місяць тому +1

    where is the github repo for this example fast API that you showed in the video?

  • @uwegenosdude
    @uwegenosdude Місяць тому

    Hi Arjan, I wish you all the best for 2025. And thanks a lot for the debugging tipps. I’m also a great fan of using the debugging features provided by my IDE. Perhaps you can add a video that shows how to debug a script which is called in a piped Linux cmdline chain like cat data | ./myscript.py -a | ./myscript.py -b
    It works with debug py but it’s tricky cause I need two debug sessions in my IDE. But I admit that is might be an edge case.

  • @MrVernuk
    @MrVernuk Місяць тому

    I use debugger not often, but it's really helpfull for me to dive deeper inside the object structure for example, which I met throughout debugging process. This helps to find some interesting things related to the object structure etc. However as far as I know and heard, not many developers actully used debugger in their developing process. They argue this by saying that their code no complex and they fully understands what the code should do. I partially agree with them, but sometimes it's hard to understand where is an error is occurred in the code.
    Arjan, what is your thoughts on this? How often you use (used) debugging in your developing routine? 🙂

  • @kapustinalexander848
    @kapustinalexander848 Місяць тому

    This is a dap protocol, and you can use this monster in any editors. Vim or emacs can do the same things.

  • @zion4d
    @zion4d Місяць тому

    Very nice, but if app dockerized it tries to connect DB in neighbor pgadmin container and fails because cant connect. Same issue with Redis.
    To fix have to change db connection address in settings. And change back before git push to VPS

    • @zion4d
      @zion4d Місяць тому

      Solved adding .envdev with DB settings and adding envFile:.envdev to launch.json.
      Of course dont forget about docker ports mapping on db and redis containers.

  • @MrSunTrope
    @MrSunTrope Місяць тому

    How can i run vscode debug for app running by docker compose?

  • @inspiredbyrd
    @inspiredbyrd Місяць тому

    Thank you for again an interesting video. Can you please review a relative new kid on the block called FastHtml, which seems a hybrid between FastApi and HTMX. I would like to hear your opinion on this.

  • @MrNiceseb
    @MrNiceseb 7 днів тому

    I already have a .venv before I started debugging, but upon the launch.json, it is asking me for a Python interpreter before I can start debugging, so instead of typing, Find... Browse your file system to find a Python interpreter, but it cannot seem to find the .venv/bin/python already created, manually typing the path of .venv keeps saying it cannot find .venv/bin/python that was created in the first place.

  • @serenditymuse
    @serenditymuse Місяць тому

    Easier to write unit test that directly call your FastAPI endpoints with a temporary db or other store under it. Also you can call endpoints directly as functions for some types of testing. I don't see why you want to debug under uvicorn if you goal is debugging your fastapi logic itself. Are you trying to debug uvicorn somehow?

  • @frydegz
    @frydegz Місяць тому

    thumbnail is crazy

  • @joschomo1010
    @joschomo1010 Місяць тому

    How show nvim

  • @matis9783
    @matis9783 Місяць тому

    you have old FastAPI logo in thumbnail

  • @Soltaiyou
    @Soltaiyou Місяць тому +1

    Total click bait! Where was the nerf gun?!?!?!

    • @ArjanCodes
      @ArjanCodes  Місяць тому +2

      It was off-camera and pointed at me to make sure I didn’t ramble too much during recording.

  • @sborkes
    @sborkes Місяць тому

    Nice video title 😂

    • @aflous
      @aflous Місяць тому

      You meant thumbnail?

    • @ArjanCodes
      @ArjanCodes  Місяць тому

      Thanks 😅

    • @Daviid_5
      @Daviid_5 Місяць тому

      ​@@aflous Nah, he's probably seeing the automated translation, same problem with shorts

    • @tswdev
      @tswdev Місяць тому

      @@Daviid_5 No, I saw it originally as a placeholder title, probably the name of the file without the extension. Arjan then edited it.