1
<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)
4

0 回答 0