我使用Flask
并且想要渲染html页面并直接关注特定的dom element
使用/#:id
。渲染html页面/#:id使用烧瓶
下面是默认/
渲染
@app.route('/')
def my_form():
return render_template("my-form.html")
下面的代码是在POST
请求被调用的函数。
@app.route('/', methods=['POST'])
def my_form_post():
#...code goes here
return render_template("my-form.html")
我想渲染我my-form.html
页面my-form.html/#output
所以它应该直接在DOM专注于所需element
。
但尝试return render_template("my-form.html/#output")
说明没有这样的文件,并且尝试@app.route('/#output', methods=['POST'])
也不起作用。
UPDATE:
考虑这个web应用程序JSON2HTML - http://json2html.herokuapp.com/
发生了什么:每当一个人点击send
按钮textarea的输入和造型设置发送到我的python后端flask-app如下。
@app.route('/', methods=['POST'])
def my_form_post():
#...code for converting json 2 html goes here
return render_template("my-form.html",data = processed_data)
我想要什么:每当send
按钮被点击和表单数据POSTED
和处理,并在同一个页面重定向与包含要显示的processed_data的新参数。我的问题是渲染同一页面附加片段标识符#outputTable
,以便在转换后,页面直接关注用户所需的所需输出。
Thanks @Miguel。请参阅最新的问题。我无法执行所需的操作。 – softvar
我在您的更新中添加了其他评论。 – Miguel