Trying to test my first FastApi code using uvicorn.
Following code written on Jupyter Notebook and saved as 'main.py' in the directory: /home/user
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
From the same directory I am running:
$uvicorn main --reload
It is throwing the following error:
ERROR: Error loading ASGI app. Import string "main" must be in format ":".
Use:
uvicorn main:app --reload
P.S. I would highly suggest to take the FastAPI tutorial, before posting further questions here.