POST requests

If a user selects an arena from the list and pushes the Find Data button, the HTML form issues a POST request to the view. With the if conditional resolving to True, the view handles the request by generating an arena location coordinate pair and a custom popup, instead of using a default coordinate pair and popup value:

  if request.method == "POST":
arena_id = form.selections.data
arena = session.query(Arena).get(arena_id)
form.longitude = round(arena.longitude,4)
form.latitude = round(arena.latitude,4)

The property form.selections.data is used to retrieve the id of the arena chosen from the list and is passed to a variable called arena_id. This id is then used to query the database through the SQLAlchemy ORM's get method. The form.longitude and form.latitude fields can be populated from data fields of the arena object returned by the query.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset