This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
241 lines (223 loc) · 6.51 KB
/
main.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
from random import choice
from flask import Flask, redirect
app = Flask(__name__)
words = {
"1": "One Direction",
"2": "Dr Who",
"3": "Cup of herbal tea",
"4": "Knock at the door",
"5": "Johnny's Alive",
"6": "Little Mix",
"7": "David Beckham",
"8": "Golden Gate",
"9": "Selfie Time",
"10": "Boris’ den",
"11": "Stranger Things",
"12": "Dirty dozen",
"13": "Unlucky for some",
"14": "Valentine’s Day",
"15": "Your claim to fame",
"16": "Sweet 16",
"17": "Dancing Queen",
"18": "Party on Tatooine",
"19": "Time for Quarantine",
"20": "Facemasks Aplenty",
"21": "Vaccines are fun",
"22": "Scooby Doo and Scrappy too",
"23": "The Bees Knees",
"24": "It's Dumbledore",
"25": "Dobbie Dies",
"26": "She's had her Weetabix",
"27": "Bridesmaid Dresses",
"28": "Over Weight",
"29": "Rise and Shine",
"30": "Liz Lemon Rocks",
"31": "Man Bun",
"32": "Jimmy Choo",
"33": "Dirty knees",
"34": "Murder on the Dance Floor",
"35": "Jump and Jive",
"36": "New Tricks",
"37": "A Hobbits Tale",
"38": "Magnum P.I.",
"39": "Love Island Time",
"40": "Hello Naughty",
"41": "Time for Fun",
"42": "Winnie the Pooh",
"43": "Fish, Chips and Pea's",
"44": "Scores on the Doors",
"45": "Halfway there",
"46": "Up to tricks",
"47": "Four and seven",
"48": "Tag a mate",
"49": "Amazon Prime",
"50": "Hawaii Five-O",
"51": "Aliens!",
"52": "Chicken Vindaloo",
"53": "Stuck in a tree",
"54": "Grannys Drawers",
"55": "Snakes alive",
"56": "Chill with Netflix",
"57": "Heinz varieties",
"58": "Make them wait",
"59": "Tequila and Lime",
"60": "Five dozen",
"61": "Baker's bun",
"62": "Turn the screw",
"63": "OMG, they killed Kennedy",
"64": "Will you still love me",
"65": "Thunderbirds are Go",
"66": "Jedi Tricks",
"67": "Retirement Heaven",
"68": "Cathrine Tate",
"69": "Moonwalk Time",
"70": "I'm holding out for a Hero",
"71": "Fox on the run",
"72": "Six dozen",
"73": "Not the Bees!",
"74": "Recycle More",
"75": "What a time to be alive",
"76": "Ripley Saves Hicks",
"77": "Sunset strip",
"78": "Haters Gunna Hate",
"79": "One more time",
"80": "Imagine!",
"81": "Girls just wana have fun",
"82": "Electric Boogaloo",
"83": "Gluten Free",
"84": "Ghostbusters",
"85": "Staying alive",
"86": "Instagram Pix",
"87": "Walk like an Egyptian",
"88": "Will and Kate",
"89": "Busta Rhyme",
"90": "Joe Ninety",
}
def init():
global previous_numbers
global numbers
previous_numbers = []
numbers = list(range(1, 91))
@app.route("/")
def root():
try:
previous_numbers
return redirect("/play", code=302)
except NameError:
init()
return redirect("/play", code=302)
@app.route("/play")
def play():
try:
number = previous_numbers[-1]
return f"""
<html>
<style>
body {{
font-family: Helvetica, Arial, Sans-Serif;
text-align: center;
background-color: black;
color: white;
}}
pre {{
white-space: pre-wrap;
font-size: 25px;
}}
.number {{
font-size: 200px;
}}
.phrase {{
font-size: 50px;
}}
.button {{
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}}
.next {{
background-color: #4CAF50;
}}
.reset {{
background-color: #f44336;
}}
</style>
<body>
<span class="number">{number}</span><br />
<span class="phrase">{words[str(number)]}</span><br />
<br />
<form action="/increment">
<input type="submit" class="button next" value="Next Number" />
</form>
<p>Previous Numbers:</p>
<pre>{' '.join(previous_numbers)}</pre>
<br />
<br />
<form action="/reset">
<input type="submit"
class="button reset"
onclick="return confirm('Are you sure?')"
value="Reset" />
</form>
</body>
</html>
"""
except IndexError:
return redirect("/gameover", code=302)
except NameError:
return redirect("/", code=302)
@app.route("/gameover")
def gameover():
return f"""
<html>
<style>
body {{
font-family: Helvetica, Arial, Sans-Serif;
text-align: center;
background-color: black;
color: white;
}}
pre {{
white-space: pre-wrap;
font-size: 50px;
}}
.gameover {{
font-size: 50px;
}}
.button {{
background-color: #f44336;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}}
</style>
<body>
<span class="gameover">Game over!!!</span><br />
<form action="/reset">
<input type="submit" class="button reset" value="Reset" />
</form>
<p>Previous Numbers:</p>
<pre>{' '.join(previous_numbers)}</pre>
</body>
</html>
"""
@app.route("/increment")
def increment():
try:
number = choice(numbers)
previous_numbers.append(str(number))
numbers.remove(number)
return redirect("/play", code=302)
except IndexError:
return redirect("/gameover", code=302)
@app.route("/reset")
def reset():
init()
return redirect("/increment", code=302)