Try removing async and just leaving def root(): and add if __name__ == "__main__":
async
def root():
if __name__ == "__main__":
from fastapi import FastAPI app = FastAPI() @app.get("/") def root(): return {"message": "Hello World"} if __name__ == "__main__":