0

I am having trouble figuring out how to return a template together with another value.

My view function looks like this:

@app.route('/', methods=['GET', 'POST'])
def index():
    page = request.args.get('page')
    return render_template('index.html', page=page)

This works fine, the problem I have is that I also need to return the value of page outside the template for another purpose but I have not been able to:

Here is an example of what I tried:

return render_template('index.html', page=page) and page

This does not work, any help will be appreciated

bgse
  • 8,237
  • 2
  • 37
  • 39
aharding378
  • 207
  • 1
  • 3
  • 16
  • You can return a tuple, but that's probably not what you want. – Ilia Choly Nov 13 '17 at 23:37
  • What do you mean exactly by "outside the template"? Can you explain the purpose so we get a better idea what you are trying? On a side note, please make sure to have proper indentation when putting Python code in your questions. – bgse Nov 13 '17 at 23:41
  • @bgse I want to do 2 separate things with the response 1 is to append the template 'index.html' to a page upon response and 2. use the value of 'page' to update another element in the page. Makes sense? Noted, about indentation – aharding378 Nov 13 '17 at 23:46

0 Answers0