frazman
frazman

Reputation: 33243

form submission not working?

I had this simple form.. where I was taking an input from user like the following

<form action="/data" autocomplete="on" method="POST">
  <input id="search" name="search" type="text" placeholder="Search for song or artists..">
<input id="search_submit" value="Submit" type="submit">
 </form>

And everything was working fine..

Now.. I wanted to add slider to it and send the slider value to python. How do i do this?

I modified the form to this:

<form action="/data" autocomplete="on" method="POST">
  <input id="search" name="search" type="text" placeholder="Search for song or artists..">
    <input type="range" min="-1" max="1" value="0" step="0.05" onchange="showValue(this.value)" /><input id="search_submit" value="Submit" type="submit">
    <span id="range" style="color:#BDBDBD">0</span>
 </form>

But it is not working I get

Bad Request

The browser (or proxy) sent a request that this server could not understand.

EDIT

@app.route("/data", methods=['POST'])
def entry_post():
    query = request.form["search"]
    print request.form["range"] # I just added this line in the code

Upvotes: 0

Views: 49

Answers (1)

eugecm
eugecm

Reputation: 1249

You are missing the "name" attribute on the range input field.

Upvotes: 1

Related Questions