0

I'm trying to pass a value row[0] to a html hyperlink below. It looks like I can use {{}} to do this in jinja2 and I did confirm that the url changed accordingly.

<a href="/editcontact?sid={{row[0]}}">EDIT</a>

The problem is I don't know how to retrieve this passed data in the linked html page below. ★★★ is where I want to put the passed row[0] value.

<form action='/editcontact' method='post'>
    <input type='text' name='sid' value='★★★' placeholder='id'>
    ...
    <input type=submit value='MODIFY'>
</form>

This is html with jinja2 template, and the server language is python(+flask).

1 Answers1

2

Since you have passed in your sid as a query parameter in <a href="/editcontact?sid={{row[0]}}">EDIT</a>, you can use the following flask code to read the query parameter in the destination page.

user = request.args.get('sid')

You can then use normal jinja2 interpolation like {{user}}

For more details on how to get query parameters in flask, see this question

Bishal
  • 807
  • 1
  • 5
  • 20