繁体   English   中英

渲染来自 python Flask 输入的文本

[英]Render A text from python Flask input

我需要从文本输入字段中呈现文本,这是我的 app.py

@app.route("/")
@app.route("/",methods=['POST'])
def data():
    text = request.form['command']
    return render_template("exploit.html") + text

if __name__ == '__main__':
    app.run(debug=1)

这是我的 exploit.html 代码

<body>
<form action="POST">
    <label>Command: </label>
    <input type="text" name = "command"> 
    <input type = "submit" value = "send">
</form>

实际上我正在尝试从该文本输入中执行一些远程代码

您可以通过将 arguments 添加到 render_template function 来将变量传递给 jinja2 模板。

    return render_template("exploit.html", text = text)

稍后可以使用 {{}} 访问它们,如下所示:

<body>
{{text}}
<form action="POST">
    <label>Command: </label>
    <input type="text" name = "command"> 
    <input type = "submit" value = "send">
</form>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM