Skip to content

Commit 86f789f

Browse files
committed
Add /dice route
1 parent 7599678 commit 86f789f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

views/dice.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html>
2+
<head>
3+
<title>Dice Roll</title>
4+
</head>
5+
<body bgcolor="yellow">
6+
<center>
7+
<br><br>
8+
<h1>Your dice roll result:</h1>
9+
<br><br>
10+
<h2 id="result">{{ random }}</h2>
11+
<p><a href="/dice">Roll it again</a></p>
12+
</center>
13+
</body>
14+
</html>

web.py

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
https://realpython.com
55
"""
6+
import random
67

78
import bottle
89

@@ -51,4 +52,9 @@ def dionysus():
5152
return bottle.template('views/dionysus.html')
5253

5354

55+
@bottle.route('/dice')
56+
def dice():
57+
return bottle.template('views/dice.html', random=random.randint(1, 6))
58+
59+
5460
app = bottle.default_app()

0 commit comments

Comments
 (0)