Skip to content

@joshfinnie /gist:5cfbe51a80914da1aebe secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Flask Sign up/Log in Template
from datetime import datetime
from flask import *
from flaskext.wtf import *
from flaskext.sqlalchemy import *
from werkzeug import generate_password_hash, check_password_hash
app = Flask()
app.config.from_pyfile('app_settings.py')
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)
self.email = 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()])
@ohadpartuck

thanks for sharing, very lightweight and useful

@hkst

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.