Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Flask Sign up/Log in Template
from datetime import datetime
from flask import *
from import *
from flaskext.sqlalchemy import *
from werkzeug import generate_password_hash, check_password_hash
app = Flask()
db = SQLAlchemy(app)
# Standard Databases
class User(db.Model):
__tablename__ = 'users'
uid = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(60))
pwdhash = db.Column(db.String())
email = db.Column(db.String(60))
activate = db.Column(db.Boolean)
created = db.Column(db.DateTime)
def __init__(self, username, password, email):
self.username = username
self.pwdhash = generate_password_hash(password) = email
self.activate = False
self.created = datetime.utcnow()
def check_password(self, password):
return check_password_hash(self.pwdhash, password)
# Standard Forms
class signup_form(Form):
username = TextField('Username', [validators.Required()])
password = PasswordField('Password', [validators.Required(), validators.EqualTo('confirm', message='Passwords must match')])
confirm = PasswordField('Confirm Password', [validators.Required()])
email = TextField('eMail', [validators.Required()])
accept_tos = BooleanField('I accept the TOS', [validators.Required])
class login_form(Form):
username = TextField('Username', [validators.Required()])
password = TextField('Password', [validators.Required()])

thanks for sharing, very lightweight and useful


do you a similar example for sqlite pls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.