The deployment page gives the following example
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=5000, log_level="info", reload=True)
This does not work for me, it gives the warning
WARNING:uvicorn:auto-reload only works when app is passed as an import string.
What works for me is something like
if __name__ == "__main__":
uvicorn.run("module:app", host="127.0.0.1", port=5000, log_level="info", reload=True)
the latter breaks with
ModuleNotFoundError: No module named 'aiofiles'
so had to
pip install aiofiles
Thanks, Patrick!
What should module be set to? When using your example, I get:
ERROR: Error loading ASGI app. Could not import module "module".
My layout is simply app/main.py, and I am running it as python3 app/main.py.
any .py file is a module. so if your entry file is main.py and "app" is the ASGI app then use "main" as the module name. ie. "main:app"
That works, thanks!
Most helpful comment
any .py file is a module. so if your entry file is main.py and "app" is the ASGI app then use "main" as the module name. ie. "main:app"