简体   繁体   English

使用 Windows 在 Heroku 上部署 python flask web 应用程序

[英]Deploying a python flask web application on Heroku with Windows

I am trying to deploy a flask app I made to Heroku with success.我正在尝试将我制作的 Flask 应用程序成功部署到 Heroku。 The app is generated but I get errors when I push the code to the Heroku repository.该应用程序已生成,但在将代码推送到 Heroku 存储库时出现错误。

My flask app is inside a module called server.py and the variable is named app.我的 Flask 应用程序位于名为 server.py 的模块中,变量名为 app。 At first I tried using gunicorn and writing web: gunicorn server:app and deplying but no web dynos were up and I get an error stating it is the Procfile file.起初我尝试使用 gunicorn 并编写 web: gunicorn server:app 和 deplying 但没有 web dynos 启动,我收到一个错误,指出它是 Procfile 文件。 Red about it about and saw that Gunicorn is not really working on windows so I tried installing Waitress and deploying without success.关于它的红色并看到 Gunicorn 并没有真正在 Windows 上工作,所以我尝试安装 Waitress 并部署但没有成功。 this time my profcile was written as all of these (tried several times):这次我的个人资料被写成所有这些(尝试了几次):

web: waitress-serve --listen=*:8000 server.wsgi:application网络:服务员服务 --listen=*:8000 server.wsgi:application

web: waitress-serve --listen=*:8000 app.wsgi:application And so on. web: waitress-serve --listen=*:8000 app.wsgi:application 等等。

to add a web dyno I should scale it because heroku ps: showes that there is no dynos.要添加网络测功机,我应该对其进行缩放,因为 heroku ps: 显示没有测功机。

When I try to run heroku ps:scale web=1 I get:当我尝试运行 heroku ps:scale web=1 时,我得到:

Scaling dynos... !缩放动态...! ▸ Couldn't find that process type. ▸ 找不到那个进程类型。

What am i doing wrong?我做错了什么?

I was having the same problem.我遇到了同样的问题。 Particularly, waitress works locally in Windows (inside a Procfile.windows file web: waitress-serve index:server , then with heroku CLI heroku local -f Procfile.windows ), but failed after Heroku deployment.特别是,服务员在 Windows 中本地工作(在 Procfile.windows 文件web: waitress-serve index:server ,然后使用 heroku CLI heroku local -f Procfile.windows ),但在 Heroku 部署后失败。 Workaround for me was to locally test with waitress (like explained), but deploy with gunicorn ( web: gunicorn index:server inside Procfile).我的解决方法是使用女服务员进行本地测试(如解释),但使用 gunicorn 进行部署( web: gunicorn index:server inside Procfile)。 Let me know if this works for you.让我知道这是否适合您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM