dimanche 16 octobre 2016

invalid syntax on python if else statement

I have the follow if/else statement in my server.py file. I'm am getting an invalid syntax error on the else statement, but cannot find the error. Could anybody find the error in my code?

Server.py file

from flask import Flask, render_template, request, redirect, session, flash
app = Flask(__name__)
app.secret_key = 'KeepItSecretKeepItSafe'

@app.route('/')
def index():
    return render_template('survey.html')

@app.route('/create', methods = ['POST'])
def create():
    data = request.form
    print data
    return render_template('results.html', data=data)

@app.route('/process', methods=['POST'])
def process():
    if len(request.form['name']) < 1:
        flash("Name cannot be empty!") 
    else:
        flash("Success! Your name is {}".format(request.form['name'])) 
    return redirect('/') 


if __name__ == "__main__":
    app.run(debug=True)

Aucun commentaire:

Enregistrer un commentaire