The error happens because of incorrect module and app name syntax — it should be uvicorn main:app --reload.
Here is the code snippet you can refer to:

In the above code we are using the following key points:
- FastAPI() initializes the web application.
- @app.get("/") sets up a route for the root endpoint.
- read_root() returns a JSON response.
- uvicorn main:app --reload properly references the module (main) and FastAPI instance (app).
Hence, using the correct syntax main:app resolves the "invalid command name" error.