Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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() login_manager.init_app(app) @app.route('/register', methods=("GET", "POST")) def register(): form = forms.SignUpForm() return render_template('register.html', form=form) @login_manager.user_loader def load_user(userid): try: return models.User.select().where( models.User.id == int(userid) ).get() except models.DoesNotExist: return None @app.before_request def before_request(): g.db = models.DATABASE g.db.connect() @app.after_request def after_request(response): g.db.close() return response
Louise St. Germain19,412 Points
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!