[英]I deployed a flask app on heroku , it was crashed immediately
我在heroku上部署了flask应用程序。 最初,用户界面打开了,但是使用页面的表单或按钮时,服务器超载,应用程序崩溃,尽管该应用程序在本地运行良好。
github上应用程序的链接是-https: //github.com/ahmedtoba/gas-lift
该应用程序的链接是-https://gas-lift.herokuapp.com/
您创建了2次路由index
=> /
@app.route('/')
def index():
result = False
return render_template('index.html', result=result)
@app.route('/',methods = ['POST', 'GET'])
因此,当您提交表单时,由于第一个装饰器默认设置为仅处理GET请求,因此不会发生任何事情。
如果要同时处理POST和GET请求,则可以这样处理:
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
(ALL CODE FROM your result function HERE)
else:
result = False
return render_template('index.html', result=result)
编辑:
我运行了您的代码。 有很多小错误,您没有遵循PEP 8标准,因此您和我都很难阅读您的代码。 提交表单后,您的request.form
数据是有效的,您都将其转换为浮点数,但是在第95行上会收到ZeroDivisionError
,因此请重新考虑将代码拆分为小部分,并检查等式的哪一部分为0。尝试拆分代码并获取调试器以帮助您评估表达式。
除此之外,祝你好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.