尽管我在网上做了很多尝试,我还是不断地犯这个错误。
我想在Heroku上运行烧瓶应用程序。
下面是我的程序文件
web gunicorn -b 127.0.0.1:8000 geeni:app
下面是我的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()
我已经设置了我的heroku推/登录的一切,并已完全遵循教程运气不好。。
最佳答案
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中硬编码。