简体   繁体   中英

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

I deployed a flask application on heroku. 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

the link of the app is - https://gas-lift.herokuapp.com/

You created 2 times route 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.

If you want to handle both POST and GET request, you can do it like so:

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

Other than that, good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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