Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Flask challenge - not passing

Your register() view needs to create an instance of the SignUpForm from forms. It should also render and return the register.html template. You'll need to import render_template. In the template's context, name the SignUpForm instance as form.

Bummer: Didn't get a 200 at '/register'.

from flask import Flask, g
from flask.ext.login import LoginManager

import forms
import models

app = Flask(__name__)
app.secret_key = 'this is our super secret key. do not share it with anyone!'
login_manager = LoginManager()

@app.route('/register', methods=("GET", "POST"))
def register():

    form = forms.SignUpForm()
    return render_template('register.html', form=form)

def load_user(userid):
        return models.User.select().where(
            models.User.id == int(userid)
    except models.DoesNotExist:
        return None

def before_request():
    g.db = models.DATABASE

def after_request(response):
    return response

1 Answer

Louise St. Germain
Louise St. Germain
19,424 Points

Hi Andrii,

I'm not a Flask expert (yet!) and I'm not sure which challenge you're doing, but as far as I know, HTTP methods in app.route need square brackets:

@app.route('/register', methods=["GET", "POST"])
# instead of
@app.route('/register', methods=("GET", "POST"))

Otherwise, if it still doesn't work, I'll defer to someone who knows more about Flask!