python - request.form.get 和 request.args.get 在烧瓶表单数据中不返回任何内容
问题描述
我试图通过单击“更多照片”的链接来获取 dirname 值。这是表单 HTML。
<form action="/single" method="GET">
<input type="text" name="dirname" value="{{ dir_name }}" style="display:none">
<a href="single.html" class="btn btn-outline-white py-2 px-4">More Photos</a>
</form>
这是烧瓶中获取此数据的函数。
@app.route('/single.html', methods=['GET', 'POST'])
@app.route('/single', methods=['GET', 'POST'])
def single():
print(request.method)
if request.method == "GET":
dir_name = request.args.get("dirname")
print("Dir name is ", dir_name)
main_path = join("static/Downloaded_images", dir_name)
images_paths, names = get_paths(main_path)
return render_template('single.html', images_paths_names=zip(images_paths,names))
这是我单击更多照片时的 URL。http://127.0.0.1:5000/single.html
如何在 URL 中传递 dirname 以使其发挥作用?目前它显示我没有。
解决方案
推荐阅读
- javascript - 如何有效地从所有组合中随机选择多个组合
- php - 使用php检查SQL数据库中是否存在电子邮件地址
- java - Java 包参考,无需更改已实现的应用程序
- python - 使用带有每个入口描述的 python boto3 授权 aws 安全组
- postgresql - 如何计算 Postgres 9.6 中唯一对的数量?
- python-2.7 - 使用python获取共享点目录中的文件列表
- c# - 在 From 中设置 Capture = true 仅捕获一次鼠标单击事件
- php - PHPunit 模拟返回始终为空
- css - 特定元素上的 CSS Grid 行/列间隙?
- soapui - 努力在soap ui中的测试用例级别引用属性值