heroku 如何从不同路径运行Fastapi应用程序

1cosmwyk  于 9个月前  发布在  其他
关注(0)|答案(2)|浏览(150)

我的repo目录看起来像

src/
notebooks/
web/
  one/
  two/
     app/

字符串
当我在two下时,我可以使用

uvicorn app.app:app --reload --host=0.0.0.0 --port=7000


然而,我将在heorku上部署我的模型,Procfile应该在主路径上。

web: uvicorn app.app:app --reload --host=0.0.0.0 --port=7000


但我不能从其他文件夹运行应用程序。它会给给予错误

ModuleNotFoundError: No module named 'app'

  • 更新 *

find web/two/app的输出如下:

所以当我运行uvicorn web.two.app.app:app --reload --port=7000
错误是

u5rb5r59

u5rb5r591#

您可以通过以下命令从不同的路径运行您的应用程序:
1x个月
在你的情况下,它将是(假设你在web/ dir中写下面的命令):
uvicorn --app-dir ./two/app app:app --reload --host=0.0.0.0 --port=7000

au9on6nz

au9on6nz2#

你必须提供从root到应用的整个路径。在你的情况下,它应该看起来像这样:
1x个月

相关问题