Python Flask - 增量request.path

时间:2017-03-30 21:16:46

标签: python-3.x flask

<a href="{{ request.path }}"></a>

我基本上希望做到以下几点:

<a href="{{ request.path = request.path +1 }}"></a>

request.path正在返回&#34; / image /&#34;。我需要增加。所以我需要增加。

这是路线:

@app.route('/image', methods=['GET', 'POST'])
@app.route('/image/<int:image_id>',methods=['GET', 'POST'])
def image(image_id):
    image = Images.query.filter_by(id=image_id).first_or_404()
    return render_template('image.html', image=image)

我应该考虑拆分路径吗?

1 个答案:

答案 0 :(得分:0)

回答我自己的问题:

在路线上将image_id传递到模板中:

m=image_id

在模板中:

<a href="{{ m+1 }}"> xx </a></li>