<form action="/image" method ="POST" name="myform" style="background-color:#E0FFFF">
<input type="hidden" value="" id="hidSrc">
<img src={{url}} width="25%" onclick="document.getElementById('hidSrc').value = this.src; document.myform.submit();">
</form>
このコードは、クリックしてフォームを送信すると、非表示フィールドに SRC を格納するようになっています。
これが私のapp.pyの受信コードです
@app.route('/image', methods=['GET', 'POST'])
def _image():
if request.method=="GET":
taglist = db.getTaglist()
tags = db.getTags(picurl)
commentlist = db.getComments(picurl)
return render_template("image.html", taglist = taglist, tags =tags, commentlist = commentlist, pic = picurl)
else:
button = request.form['button']
if button=="submit":
aComment = request.form['comment']
db.addComment(picurl,aComment)
elif button == "submitnewtag":
if request.form['Addnewtag']:
aTag = request.form['Addnewtag']
db.addTag(picurl,aTag)
else:
aTag = request.form['select1']
db.addTag(picurl,aTag)