For context, I'm trying to create a flask-wtf form. I've done that and it's presented correctly:
class LoginForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
submit = SubmitField('Sign In')
@APP.route('/')
def index():
return render_template('login.html', form=LoginForm())
@APP.route('/login', methods=['POST', 'GET'])
def login():
print(request.method, request.get_json())
return redirect('/') # temporary
Here's the html:
{% block content %}
<h1>Sign In</h1>
<form action="/login" method="post" enctype='application/json'>
{{ form.hidden_tag() }}
<p>
{{ form.username.label }}<br>
{{ form.username(size=32) }}
</p>
<p>
{{ form.password.label }}<br>
{{ form.password(size=32) }}
</p>
<p>{{ form.submit() }}</p>
</form>
{% endblock %}
However, when I enter anything and click submit, what gets printed from login() is POST None. I don't understand why there's no data being sent. As an attempt to force it to be json, I added enctype='application/json' and nothing before or after.
What am I missing?