Reputation: 6080
my repo directory looks like
src/
notebooks/
web/
one/
two/
app/
when I am under two
I can lunch my fastapi
app using
uvicorn app.app:app --reload --host=0.0.0.0 --port=7000
however, I am going to deploy my model on heorku and the Procfile should be at the main path. I know I have to make a Procfile and add
web: uvicorn app.app:app --reload --host=0.0.0.0 --port=7000
but I can't run the app from other folders. It would give the error
ModuleNotFoundError: No module named 'app'
UPDATE
the output of find web/two/app
is as following
so when I run uvicorn web.two.app.app:app --reload --port=7000
Upvotes: 12
Views: 14047
Reputation: 91
You can run your app from different path by following below command:
uvicorn --app-dir <path-to-your-app/main file> <main-file-name>:<object-of-FastAPI> --reload --host 0.0.0.0 --port 7000
In your case it will be (assuming you are writing below command in web/ dir):
uvicorn --app-dir ./two/app app:app --reload --host=0.0.0.0 --port=7000
Upvotes: 9
Reputation: 302
You have to provide the entire path from root to the app. In your case it should look like this:
uvicorn web.two.app.app:app --reload --host=0.0.0.0 --port=7000
Upvotes: 13