我无法从框架中访问所有按钮,只有直方图按钮可以使用。以下是我的表单,我希望在POST方法中访问它。
<form id="package_form" action="" method="post">
<div class="panel-body">
<input type ="submit" name="Download" value="Download">
</div>
<div class="panel-body">
<input type ="submit" name="Histogram" value="Histogram">
</div>
<div class="panel-body">
<input type ="submit" name="Search" value="Search">
</div>
</form>
这是我的Python代码。
if request.method == 'GET':
return render_template("preview.html", link=link1)
elif request.method == 'POST':
if request.form['Histogram'] == 'Histogram':
gray_img = cv2.imread(link2,cv2.IMREAD_GRAYSCALE)
cv2.imshow('GoldenGate', gray_img)
hist = cv2.calcHist([gray_img], [0], None, [256], [0, 256])
plt.hist(gray_img.ravel(), 256, [0, 256])
plt.xlabel('Pixel Intensity Values')
plt.ylabel('Frequency')
plt.title('Histogram for gray scale picture')
plt.show()
return render_template("preview.html", link=link1)
elif request.form.get['Download'] == 'Download':
response = make_response(link2)
response.headers["Content-Disposition"] = "attachment; filename=link.txt"
return response
elif request.form.get['Search'] == 'Search':
return link1
我做错了什么?
action
的输入框? - Barmar