Python Flask-如何在将表单中收集的数据发送到模板之前更改数据?
我在表单(userinput.html)中收集了一些数据: 我将其发送到模板(result.html):Python Flask-如何在将表单中收集的数据发送到模板之前更改数据?,python,flask,Python,Flask,我在表单(userinput.html)中收集了一些数据: 我将其发送到模板(result.html): {键的%result.items()中的值%} {{key}} {{value}} {%endfor%} 是否有方法在.py脚本中更改收集的数据(例如,在收集数据之后但在将其发送到模板之前,Link=“链接为-”+Link和limit+=10) <html> <body> <form action = "result" metho
{键的%result.items()中的值%}
{{key}}
{{value}}
{%endfor%}
是否有方法在.py脚本中更改收集的数据(例如,在收集数据之后但在将其发送到模板之前,Link=“链接为-”+Link
和limit+=10
)
<html>
<body>
<form action = "result" method = "POST">
<p>Link <input type = "text" name = "Link" /></p>
<p>Limit <input type = "text" name = "Limit" /></p>
<p><input type = "submit" value = "submit" /></p>
</form>
</body>
</html>
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def userinput():
return render_template('userinput.html')
@app.route('/result',methods = ['POST', 'GET'])
def result():
if request.method == 'POST':
result = request.form
return render_template("result.html",result = result)
if __name__ == '__main__':
app.run()
<!doctype html>
<html>
<body>
<table border = 1>
{% for key, value in result.items() %}
<tr>
<th> {{ key }} </th>
<td> {{ value }} </td>
</tr>
{% endfor %}
</table>
</body>
</html>