发送数据到服务器烧瓶html [英] Sending data to server flask html
问题描述
< form 我试图创建一个简单的复选框,将数据发送到服务器。行动= 。方法= POST >
< div class =checksheet>
< input id =XML Parserclass =checkboxtype =checkbox/> XML Parser
< input id =Feed Parserclass =checkbox文本解析器
<输入id =文本解析器class =checkboxtype =checkbox/> class =checkboxtype =checkbox/> Case Normalization
< input id =Stemmerclass =checkboxtype =checkbox/> Stemmer
< / div>
< div class =submit>< input type =submitvalue =Sendname =raw_text>< / div>
< / form>
我想要做的事与此处提出的问题非常相似: 但是我得到这个错误: MY服务器端代码(在烧瓶中)是: 有任何建议。 您的复选框元素需要 要访问复选框,需要 I am trying to create a simple checkbox that sends the data to server here is my html code. What I am trying to do is very similar to the question asked here: Send Data from a textbox into Flask?
But except with the text box.. I have checkboxes. But I get this error: MY server side code (in flask) is: Any suggestions.
Thanks A few things: Your checkbox elements need a Your To be accessible the check boxes need
这篇关于发送数据到服务器烧瓶html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
除了使用文本框..我有复选框。
未找到
在服务器上未找到请求的URL。
如果您手动输入网址,请检查您的拼写,然后重试。
@ app.route('/ raw_text.html')
def home():
file =sample.xml
contents = open(file).read()
$ b $ content = content.decode('utf-8')
return render_template('raw_text.html',contents = contents,file = file)
@ app.route('/ raw_text.html',methods = ['POST'])
def get_data():
printREQUEST,request.form )
data = request.form ['raw_text']
print data
returnProcessed
谢谢
名称
属性,这是将数据发送到后端时使用的属性。每个相互关联的复选框都必须有相同的名称
。
< label>
s ,
<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>
Not Found
The requested URL was not found on the server.
If you entered the URL manually please check your spelling and try again.
@app.route('/raw_text.html')
def home ():
file = "sample.xml"
contents = open(file).read()
contents = contents.decode('utf-8')
return render_template('raw_text.html', contents=contents,file=file)
@app.route('/raw_text.html',methods=['POST'])
def get_data():
print "REQUEST ",request.form()
data = request.form['raw_text']
print data
return "Processed"
name
attribute, this is what is used when the data is sent to the back end. Each checkbox that is related to each other needs to have the same name
.action
attribute needs to point to a URL. If you are posting it to the same page as the form, you can remove the attribute.ID
's cannot contain spaces.<label>
s,