Starting on line (8), we use the Flask @app.route() decorator to define a callback method that is invoked when the server receives an HTTP GET request from a client to the root URL /, that is, a request to http://localhost:5000:
# @app.route applies to the core Flask instance (app).
# Here we are serving a simple web page.
@app.route('/', methods=['GET']) # (8)
def index():
"""Make sure index_api_client.html is in the templates folder
relative to this Python file."""
return render_template('index_api_client.html',
pin=LED_GPIO_PIN) # (9)
On line (9), render_template('index_api_client.html', pin=LED_GPIO_PIN) is a Flask method use to return a templated page to the requesting client. The pin=LED_GPIO_PIN parameter is an example of how to pass a variable from Python to the HTML page template for rendering. We will...