Wednesday, 15 August 2012

python - Sending data to server flask html -



python - Sending data to server flask html -

i trying create simple checkbox sends info server here html code.

<form action="." method="post"> <div class="checksheet"> <input id="xml parser" class="checkbox" type="checkbox"/>xml parser <input id="feed parser" class="checkbox" type="checkbox"/>feed parser <input id="text parser" class="checkbox" type="checkbox"/>text parser <input id="case normalization" class="checkbox" type="checkbox"/>case normalization <input id="stemmer" class="checkbox" type="checkbox"/> stemmer </div> <div class="submit"><input type="submit" value="send" name="raw_text"></div> </form>

what trying similar question asked here: send info textbox flask? except text box.. have checkboxes.

but error:

not found requested url not found on server. if entered url manually please check spelling , seek again.

my server side code (in flask) is:

@app.route('/raw_text.html') def home (): file = "sample.xml" contents = open(file).read() contents = contents.decode('utf-8') homecoming render_template('raw_text.html', contents=contents,file=file) @app.route('/raw_text.html',methods=['post']) def get_data(): print "request ",request.form() info = request.form['raw_text'] print info homecoming "processed"

any suggestions. thanks

a few things:

your checkbox elements need name attribute, used when info sent end. each checkbox related each other needs have same name.

your action attribute needs point url. if posting same page form, can remove attribute.

id's cannot contain spaces.

to accessible check boxes need <label>s,

python html flask

No comments:

Post a Comment