Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LoginForm(Form):
- #username and password text boxes and a submit button
- username = StringField('username', validators=[DataRequired()])
- password = PasswordField('password', validators=[DataRequired()])
- submit = SubmitField('Log In')
- # Response to a POST triggered by clicking the submit button
- def post(self):
- # Check that the submit button was clicked (not necessary: it's the only button, but hey)
- if self.submit.data:
- session = Database.DataSession()
- # Validate username and password
- if session.query(User).filter(and_(User.username==self.username.data, User.password == self.password.data)).count() > 0:
- session['valid'] = True
- return redirect("/main")
- else:
- return redirect("/")
- # Response to a GET request
- def get(self):
- return render_template('login.html',
- title='Sign In',
- year=datetime.now().year,
- form=self)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement