Flask receiving no data for HTML POST

flask, python

Solution

You are missing field names (which are keys for `ImmutableMultiDict`, that's why it appears to be empty when form gets submitted).

change

<input type="text" id="email" placeholder="Email">

to

<input name="<whatever_email_name>" type="text" id="email" placeholder="Email">

and

<input type="password" id="password" placeholder="Password">

to

<input name="<whatever_password_name>" type="password" id="password" placeholder="Password">

Problem

``` @app.route('/', methods=['GET', 'POST']) def login(): if request.method == 'GET': if 'USER_TOKEN' in session: return make_response(render_template('index.html')) return make_response(render_template('login.html')) if request.method == 'POST': print 'data :', request.form return make_response(render_template('index.html')) ``` My `HTML` is ``` <form class="form-horizontal" action="/" method="POST"> <div class="control-group"> <label class="control-label" for="email">Email</label> <div class="controls"> <input type="text" id="email" placeholder="Email"> </div> </div> <div class="control-group"> <label class="control-label" for="password">Password</label> <div class="controls"> <input type="password" id="password" placeholder="Password"> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" class="btn">Sign In</button> </div> </div> </form> ``` When I submit data from HTML page, I see ``` data : ImmutableMultiDict([]) ``` Why the data is missing?

Original source