Files
004_comission/tunmnlu/task_1/Q5-ref/flaskapp/routes.py
louiscklaw 3688f9ee24 update,
2025-01-31 22:17:25 +08:00

27 lines
1.1 KiB
Python

""" routes.py - Flask route definitions
Flask requires routes to be defined to know what data to provide for a given
URL. The routes provided are relative to the base hostname of the website, and
must begin with a slash."""
from flaskapp import app
from flask import render_template
from wrangling_scripts.wrangling import data_wrangling, username
header, table = data_wrangling()
# The following two lines define two routes for the Flask app, one for just
# '/', which is the default route for a host, and one for '/index', which is
# a common name for the main page of a site.
#
# Both of these routes provide the exact same data - that is, whatever is
# produced by calling `index()` below.
@app.route('/')
@app.route('/index')
def index():
"""Renders the index.html template"""
# Renders the template (see the index.html template file for details). The
# additional defines at the end (table, header, username) are the variables
# handed to Jinja while it is processing the template.
return render_template('index.html', table=table, header=header,
username=username())