INNER CODE UNIT · Python
LoginForm
metafy-social/python-scripts · scripts/Authentication System using Flask/main.py:39
class LoginForm(FlaskForm):
username = StringField(validators=[InputRequired(), Length(min=4, max=20)], render_kw={"placeholder": "Username"})
password = PasswordField(validators=[InputRequired(), Length(min=4, max=20)], render_kw={"placeholder": "Password"})
submit = SubmitField("Login")
@app.route('/')
def home():
return render_template('home.html')
@app.route('/dashboard', methods=["GET", "POST"])
@login_required
def dashboard():
return render_template('dashboard.html')
@app.route('/logout', methods=["GET", "POST"])
@login_required
def logout():
logout_user()