Answer the question
In order to leave comments, you need to log in
How can I see the values that I wrote in the fields?
{% extends "base.html" %}
{% block content %}
<h1>Авторизация</h1>
<form action="" method="post" novalidate>
{{ form.hidden_tag() }}
<p>
{{ form.username.label }}<br>
{{ form.username(class="form-control") }}<br>
{% for error in form.username.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</p>
<p>
{{ form.password.label }}<br>
{{ form.password(class="form-control", type="password") }}<br>
{% for error in form.password.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</p>
<p>{{ form.remember_me() }} {{ form.remember_me.label }}</p>
<p>{{ form.submit(type="submit", class="btn btn-primary") }}</p>
</form>
{% endblock %}
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField
from wtforms.validators import DataRequired
from flask import Flask, url_for
from flask import render_template
from flask import redirect
app = Flask(__name__)
app.config['SECRET_KEY'] = 'yandexlyceum_secret_key'
class LoginForm(FlaskForm):
username = StringField('Логин', validators=[DataRequired()])
password = PasswordField('Пароль', validators=[DataRequired()])
remember_me = BooleanField('Запомнить меня')
submit = SubmitField('Войти')
print('1')
print(username)
@app.route('/login', methods=['GET', 'POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
return redirect('/success')
return render_template('login.html', title='Авторизация', form=form)
if __name__ == '__main__':
app.run(port=8080, host='127.0.0.1')
once againAnswer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question