-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello.py
40 lines (27 loc) · 846 Bytes
/
hello.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from flask import Flask, render_template
#create a Flask Instance
app = Flask(__name__)
#create a route decorator
@app.route('/')
def index():
first_name = "BoB"
stuff = "not bold txt"
favourite_pizza = ["Pepperoni", "Cheese", "mushroom", "meatfeast", 555]
return render_template("index.html",
first_name=first_name,
stuff=stuff,
favourite_pizza=favourite_pizza)
#0.0.0.0/user/johnetc
@app.route('/user/<name>')
def user(name):
return render_template("user.html", name=name)
#404 page not found
@app.errorhandler(404)
def page_not_found(e):
return render_template("404.html"), 404
#Internal server error
@app.errorhandler(500)
def page_not_found(e):
return render_template("500.html"), 500
if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True)