python - 将数据从烧瓶 python 传递到 HTML 表单
问题描述
我正在尝试通过GET
请求将值传递给 HTML 表单,就像使用 WTForms 一样。我想用一些文本预先填充表单字段。当用户编辑值并单击提交时,新值将在数据库中发布和更新。我应该使用GET
请求来做到这一点吗?下面是我正在尝试做的一个示例
@app.route("/myroute", methods=["GET", "POST"])
def myroute():
if request.method == 'GET':
request.form['field1'] = 'some text'
request.form['fields'] = 'some text'
编辑:这就是使用 WTForms 的方式
form = SomeForm()
if request.method == 'GET':
form.field1.data = 'some text'
form.field2.data = 'some text'
这可能吗?
解决方案
推荐阅读
- python-3.x - HTML 中缺少的 Web 抓取文本
- r - 为匹配的行生成 NA
- kubernetes - 如何使用 Cloud Composer 在外部集群中调度 Kubernetes 工作负载
- python-3.x - 有没有办法在 python 中读取命令行字典或 json 参数
- buildbot - 定义构建步骤时如何从 src::branch 属性计算值
- embedded - 设置 U-boot 以使用嵌入到二进制文件中的 DTB
- java - JavaFX 在 Gnome 上找不到字体
- javascript - 如何将外部json文件分配为其他文件中的变量
- python - 在循环中获取第二个值
- python - pandas - 分配排名下降的金额