Skip to content
Advertisement

FastAPI with uvicorn getting 404 Not Found error

I’m trying (failing) to set up a simple FastAPI project and run it with uvicorn. This is my code:

JavaScript

This is what I run from the terminal:

JavaScript

As you see, I get a 404 Not found. What could be the reason? Some network-related stuff, possibly firewall/vpn blocking this connection or something else? I’m new to this. Thanks in advance!

Advertisement

Answer

You need to use a decorator like this: @app.get('/'). Take a look at the FastAPI Docs.

Additionally, take a look at how decorators work in general to get a better idea of how things work behind the scenes.

Some resources for you:

python docs

one of many articles I was able to find

another SO question

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement