From 57bd5d2edb4946e60d7e83bd5195fd00a97be0ac Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 29 Oct 2018 19:52:51 +0100 Subject: [PATCH 1/2] Display a random number --- slider.py | 3 ++- templates/hello.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/slider.py b/slider.py index f9a15bc..92cbadf 100755 --- a/slider.py +++ b/slider.py @@ -1,12 +1,13 @@ #!/usr/bin/python3 from flask import Flask, render_template +from random import randint app = Flask(__name__) @app.route("/") def hello(): - return render_template("hello.html") + return render_template("hello.html", num = randint(1, 23)) if __name__ == "__main__": app.run() diff --git a/templates/hello.html b/templates/hello.html index d8a4ccc..54d1f8f 100644 --- a/templates/hello.html +++ b/templates/hello.html @@ -1 +1 @@ -Hello Slider! +Hello slider number {{ num }}! From d45d1347bded351296881f862b0184db1c998645 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 29 Oct 2018 20:35:45 +0100 Subject: [PATCH 2/2] Serve a static image (not included) --- slider.py | 4 +++- templates/hello.html | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/slider.py b/slider.py index 92cbadf..db343c8 100755 --- a/slider.py +++ b/slider.py @@ -5,9 +5,11 @@ from random import randint app = Flask(__name__) + @app.route("/") def hello(): - return render_template("hello.html", num = randint(1, 23)) + return render_template("hello.html", num=randint(1, 23)) + if __name__ == "__main__": app.run() diff --git a/templates/hello.html b/templates/hello.html index 54d1f8f..77172c2 100644 --- a/templates/hello.html +++ b/templates/hello.html @@ -1 +1,6 @@ -Hello slider number {{ num }}! + + +

Hello slider number {{ num }}!

+

+ +