Heroku 错误 R10(启动超时)-> Web 进程未能在启动后 60 秒内绑定到 $PORT

Dil*_*lli 3 python heroku flask

尽管在互联网上尝试了一切,但我仍然收到此错误。我正在尝试在 Heroku 上运行我的烧瓶应用程序。

下面是我的 ProcFile

web gunicorn -b 127.0.0.1:8000 geeni:app 
Run Code Online (Sandbox Code Playgroud)

下面是我的 geeni.py 文件。

class ChargeUser(Resource):
    def post(self):
        jsonData = request.get_json(force=True)
        stripeid = jsonData['stripeid_customer']
        currency = jsonData['currency']
        amount = jsonData['amount']
        apiKey = jsonData['api_key']
        try:
            stripe.Charge.create(amount = amount, source=stripeid, currency=currency)
            return jsonify({'Msg':'Charged!'})
        except:
            raise

api.add_resource(ChargeUser,'/')
if __name__ == '__main__':
    app.run()
Run Code Online (Sandbox Code Playgroud)

我已经设置了我的 heroku 推送/登录一切,并且已经完全遵循教程。没运气..

在此处输入图片说明

bim*_*api 5

您的 Procfile 应该是web: gunicorn -b 0.0.0.0:$PORT greeni:app. 正如目前所写,Heroku 永远不会看到您的应用程序已准备好接收入站连接:

  • 127.0.0.1接口不会接收任何外部网络流量。相反,该0.0.0.0字符串确实绑定到所有外部接口。
  • Heroku 通过$PORT变量传递所需的端口,该变量通常为 5000。

请记住 - Heroku 管理“路由网格”,它接收入站 HTTP 流量,然后将其转发到您的应用程序。它分配地址和端口,不能在您的 Procfile 中进行硬编码。