34 lines
883 B
Python
34 lines
883 B
Python
from flask import Flask, render_template
|
|
#This page is based on the following tutorial series:
|
|
#https://www.youtube.com/watch?v=0Qxtt4veJIc&list=PLCC34OHNcOtolz2Vd9ZSeSXWc8Bq23yEz
|
|
|
|
#create a flask instance
|
|
app = Flask(__name__)
|
|
|
|
#create a route decorator
|
|
@app.route('/')
|
|
|
|
#use the route decorator to bind the view function
|
|
# def index():
|
|
# return "<h1>Hello World</h1>"
|
|
|
|
def index():
|
|
return render_template('index.html')
|
|
|
|
#localhost:5000/user/John
|
|
@app.route('/user/<name>')
|
|
|
|
def user(name):
|
|
stuff = "This is some <strong> bold </strong> text"
|
|
liste = [1,2,3,4,5]
|
|
return render_template('user.html', name=name,
|
|
stuff=stuff,
|
|
liste=liste)
|
|
|
|
@app.errorhandler(404)
|
|
def page_not_found(e):
|
|
return render_template('404.html')
|
|
|
|
@app.errorhandler(500)
|
|
def page_not_found(e):
|
|
return render_template('500.html') |