【问题标题】:HTML POST method not displaying result [duplicate]HTML POST方法不显示结果[重复]
【发布时间】:2020-07-31 12:29:08
【问题描述】:

我试图让结果显示在 web 中,但只获取 html 代码中指定的参数,而不是使用表单进行的实际条目。 表单接受一个字符串,然后应该显示为结果,但我只得到下面的输出。

我是新手,请多多指教。

@app.route('/dibble2', methods=["GET", "POST"])
def dibble2():
    if request.method == "POST":
        input1 = None
        input1 = str(request.form["input1"])
        if input1 is not None:  
            result = is_create_ds(string1)
            return render_template("outco.html", result = result)

    return render_template("inco.html")

提交输入的字符串后,我显示的输出是:

结果检查:{result}

它应该输出如下内容:

结果检查:好的

这是它调用的html代码:

<html>
    <body>
        <p>Result Check: {result}</p>
        <p><a href="/dibble2">Try Again</a>
    </body>
</html>

【问题讨论】:

    标签: html flask


    【解决方案1】:

    刚刚在某个地方看到我需要在 HTML 文件中使用双括号。

    现在可以了。

    <html>
        <body>
            <p>Result Check: {{result}}</p>
            <p><a href="/dibble2">Try Again</a>
        </body>
    </html> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-17
      • 2019-09-02
      • 1970-01-01
      • 1970-01-01
      • 2021-02-23
      • 2015-02-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多