简体   繁体   English

我在heroku上部署了flask应用程序,它立即崩溃了

[英]I deployed a flask app on heroku , it was crashed immediately

I deployed a flask application on heroku. 我在heroku上部署了flask应用程序。 At first the user interface opened but when using forms or buttons of the page, the server overloaded and the app crashed, although the app worked well locally. 最初,用户界面打开了,但是使用页面的表单或按钮时,服务器超载,应用程序崩溃,尽管该应用程序在本地运行良好。

the link of the app on github is - https://github.com/ahmedtoba/gas-lift github上应用程序的链接是-https: //github.com/ahmedtoba/gas-lift

the link of the app is - https://gas-lift.herokuapp.com/ 该应用程序的链接是-https://gas-lift.herokuapp.com/

You created 2 times route index => / 您创建了2次路由index => /

@app.route('/')

def index():
   result = False
   return render_template('index.html', result=result)

@app.route('/',methods = ['POST', 'GET'])

So when you submit form, nothing happens because of first decorator that is set only to handle GET request by default. 因此,当您提交表单时,由于第一个装饰器默认设置为仅处理GET请求,因此不会发生任何事情。

If you want to handle both POST and GET request, you can do it like so: 如果要同时处理POSTGET请求,则可以这样处理:

@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)

EDIT: 编辑:

I runned your code. 我运行了您的代码。 There are lot of small mistakes and you don't follow PEP 8 standard, so it's very hard for you and for me to read your code. 有很多小错误,您没有遵循PEP 8标准,因此您和我都很难阅读您的代码。 Your request.form data after submitting a form is valid, you convert all to floats, but on line 95 you get ZeroDivisionError , so please reconsider to split your code into small parts and check what part of equation is 0. Try to split code and get debugger to help you out evaluate expressions. 提交表单后,您的request.form数据是有效的,您都将其转换为浮点数,但是在第95行上会收到ZeroDivisionError ,因此请重新考虑将代码拆分为小部分,并检查等式的哪一部分为0。尝试拆分代码并获取调试器以帮助您评估表达式。

Other than that, good luck. 除此之外,祝你好运。

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

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