Javascript HTML脚本,用于处理瓶子返回的消息

Javascript HTML脚本,用于处理瓶子返回的消息,javascript,python,html,bottle,Javascript,Python,Html,Bottle,我正在用瓶子编写一个小脚本,通过POST从HTML中读取用户输入。我想将结果从瓶子函数发送回HTML,该函数可以由HTML中的脚本进行分析 瓶子代码: @app.route("/") def index(): return template("user_info.tpl", message = "please enter your data: ") @app.route("/", method="POST") def formhandler(): x = int(request

我正在用瓶子编写一个小脚本,通过POST从HTML中读取用户输入。我想将结果从瓶子函数发送回HTML,该函数可以由HTML中的脚本进行分析

瓶子代码:

@app.route("/")
def index():
    return template("user_info.tpl", message = "please enter your data: ")
@app.route("/", method="POST")
def formhandler():

    x = int(request.forms.get('x'))
    y = int(request.forms.get('y'))
    piece = request.forms.get("value")
    final_output = int(slope)*int(value) + int(intercept)
    return template("user_info.tpl", message=str(final_output))
app.run(host="localhost", port = 8080, debug = True)
迄今为止我的HTML:

 <html>
 <head>
 <title>Form Example</title>

 </head>
 <body>
   <form method="post" action="/">
   <fieldset>
    <legend>SAMPLE FORM</legend>
    <ul>
      <li>Enter the row: <input name='x'>
      </li>
      <li>Enter the column: <input name='y'>
      </li>
      <li>Enter the piece name: <input name ="name">
      </li>
    </ul><input type='submit' value='Submit Form'>
  </fieldset>
</form>

<p>Quantitity: {{message}}</p>

<script type="text/javascript">
if (message >= 100)
{
  window.alert("Too high");
}
else {

  window.alert("Just perfect");
}

</script>


在我的HTML文件中,我试图运行一个非常简单的脚本来分析返回的值。但是,即使我输入了与控制条件匹配的值,也不会触发弹出窗口。如何解决此问题?

我发现几乎没有可能的问题:

request.forms.getvalue-表单上没有值字段 最终输出=intslope*intvalue+intintercept-代码中未提及斜率和截距 JS中没有message变量,因此将var message={{message}}添加到节中
如果{{message}}>=100,则需要给出javascript if条件,然后才能在那里获得变量,如果需要,可以转到控制台检查脚本中的值。非常感谢!你指出了确切的缺陷。现在可以了。