烧瓶-提交按钮值

时间:2018-11-04 10:31:40

标签: python html5 flask

我正在Flask中使用此表单,到目前为止,它的运行情况还不错:

<form action = "/guess/" method = "post">
     <p>Your guess:</p>
     <p><input type = "text" name = "guess" /></p>
     <p><input type = "submit" value = "Submit" /></p>
     <p>{{ guess }}</p>
     <p>{{ used }}</p>
     <p>{{ user}}{{ score }}</p>
</form>

但是可以让按钮向我的脚本发送字符串“ example”吗?

<form action = "/guess/" method = "post">
     <p>Your guess:</p>
     <p><input type = "text" name = "guess" /></p>
     <p><input type = "submit" value = "Submit" /></p>
     <p>{{ guess }}</p>
     <p>{{ used }}</p>
     <p>{{ user}}{{ score }}</p>
     <button type="submit" value="example" name="guess">Example</button>
</form>

我需要向脚本发送某些字符串

1 个答案:

答案 0 :(得分:1)

好吧,现在我在烧瓶python脚本中知道了:

guess = request.form["guess"]

要求它的价值。重复的请求必须删除:

<form action = "/guess/" method = "post">
 <p>Your guess:</p>
 <p>{{ guess }}</p>
 <p>{{ used }}</p>
 <p>{{ user}}{{ score }}</p>
 <button type="submit" value="example" name="guess">Example</button>