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.

Python A Social Network with Flask Takin' Names Form View

i need help with this one and possibly the other tasks.. syntaxError and 200 error was the two things that keep..


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()

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

@app.route('/register', methods=('GET', 'POST')) 
return ("register")
import datetime

from flask.ext.bcrypt import generate_password_hash
from flask.ext.login import UserMixin
from peewee import *

DATABASE = SqliteDatabase(':memory:')

class User(Model):
    email = CharField(unique=True)
    password = CharField(max_length=100)
    join_date = DateTimeField(default=datetime.datetime.now)
    bio = CharField(default='')

    class Meta:
        database = DATABASE

    def new(cls, email, password):

def initialize():
    DATABASE.create_tables([User], safe=True)
from flask_wtf import Form
from wtforms import StringField, PasswordField
from wtforms.validators import DataRequired, Email, Length

class SignUpForm(Form):
    email = StringField(validators=[DataRequired(), Email()])
    password = PasswordField(validators=[DataRequired(), Length(min=8)])

1 Answer

Jeff Muday
Jeff Muday
Treehouse Moderator 27,497 Points

So close! You forgot to put in your define function def register(): line.

This is part 1 of 3, the next parts will require a deeper understanding of imports, forms, and models. So make sure to read the instructions carefully because if you forget to import or namespace, it won't quite work.

Good luck with your Python journey!!

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