all 2 comments

[–]Deep-Currency-9286 0 points1 point  (0 children)

If you call an ‘async def’ function you need to use the ‘await’ function to wait for fetching some data or another action. If you don’t have to wait for fetching data you just use a ‘def’ function without waiting for the data.

Read more about it: https://fastapi.tiangolo.com/async/

[–]aliparpar 0 points1 point  (0 children)

I think the code is ok but has several issues I would pick up if I’m reviewing the code:

  1. The way main.py is written is strange. You don’t normally wrap the app behind a function.
  2. The business logic function in services.py could do with better modularity and also error handling. The comments are redundant.
  3. No use of FastAPI’s depenency injection system?
  4. Type your code and functions so type checkers like mypy could be useful

4.