Passing an integer via URL in Flask App

From TRCCompSci - AQA Computer Science
Revision as of 12:46, 13 February 2020 by Admin (talk | contribs) (Created page with "One of the key skills for web apps will be to pass a variable using the URL. =Edit the 'app.route'= You need to add the parameter in '<' & '>' brackets. The 'int' is the data...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

One of the key skills for web apps will be to pass a variable using the URL.

Edit the 'app.route'

You need to add the parameter in '<' & '>' brackets. The 'int' is the data type:

@app.route("/product/<int:param>/")

Edit the def

You will need to add the name of the parameter from the 'app.route' string:

def go_to(param):

Using the parameter

This variable is now available in the entire 'def' for this route.