Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import with_statement
- from sqlite3 import dbapi2 as sqlite3
- from flask import Flask, request, session, g, redirect, url_for, abort, \
- render_template, flash
- from conf import appconf.cfg
- from flaskext.bcrypt import bcrypt_init, generate_password_hash, \
- check_password_hash
- from flaskext.wtf import Form, TextField, TextAreaField, PasswordField, \
- SubmitField, Required, ValidationError, validators
- from wtforms import Form, BooleanField, TextField, validators
- import os
- app = Flask(__name__)
- app.config.from_object(appconf.cfg)
- bcrypt_init(app)
- class LoginForm (wtf.Form):
- email = wtf.TextField("Email",[validators.Length(min=8, max=40)])
- password = wtfPasswordField("Password",[validators.Length(min=6, max=20)])
- submit = SubmitField("Let me in")
- forgotPassword = TextField("Email")
- def validate_email(self,email):
- check_user = Users.query.filter_by(email = email.data).first()
- if check_user is None: #if there is no one by that email
- raise ValidationError, "Nope, nobody by that email"
- def connect_db():
- return sqlite3.connect(app.config['DATABASE'])
- @app.before_request
- def before_request():
- g.db = connect_db()
- @app.after_request
- def after_request(response):
- g.db.close()
- return response
- @app.route('/')
- def index():
- return render_template('index.html')
- @app.route('/login')
- def login():
- return render_template('login.html')
- if __name__ == '__main__':
- app.run()
Add Comment
Please, Sign In to add comment