Peter Safwat
Peter Safwat

Reputation: 47

Flask : BuildError

@app.route('/sign/<error>')
def sign(error=''):
    return render_template('sign.html',er=error)
@app.route('/process', methods=['POST','GET'])
def process():
    ch = request.form['box']
    if ch == 'ok':
        name = request.form['name']
        comment = request.form['comment']

        signature = Comments(name=name, comment=comment)
        db.session.add(signature)
        db.session.commit()
        return redirect(url_for('index'))
    else :
        er='please check'
        return redirect(url_for('sign',error=er))

sign.html have this line of code

<div style="color: red;">{{er}}</div>
this is a picture for what i get BuildError: Could not build url for endpoint 'sign'. Did you forget to specify values ['error']?

Upvotes: 0

Views: 81

Answers (2)

mikky
mikky

Reputation: 1

Error occurred because /sign/error, error is none. Either you can try changing def sign(error='') to def sign(error), or change er='please check' to 'pleasecheck'(that doesn't contain blank)

Upvotes: 0

Matt Healy
Matt Healy

Reputation: 18531

The bottom of your traceback is cut off, but it looks like in your index.html template you're calling url_for for your sign route without specifying a value for error.

Upvotes: 1

Related Questions