-
Notifications
You must be signed in to change notification settings - Fork 3
/
flask_pyGlialo.py
60 lines (44 loc) · 1.62 KB
/
flask_pyGlialo.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
# -*- coding: utf-8 -*-
from flask import Flask, render_template, redirect, url_for
from pyglialo import pyglialo
app = Flask(__name__)
@app.route('/')
@app.route('/reset')
def index():
pyglialo.load_meetup_data()
return render_template('index.html', event=pyglialo.event)
@app.route('/random')
def spread_the_goodies():
pyglialo.extract_safe_winner()
if pyglialo.winner:
lead_text = 'Rolling for goodies Number {}'.format(len(pyglialo.list_of_winners) + 1)
else:
lead_text = 'No one else can win!!!'
return render_template('random.html', winner=pyglialo.winner, winners=pyglialo.list_of_winners, lead_text=lead_text)
@app.route('/save/<name>/')
def save_winner(name):
if name not in pyglialo.list_of_winners:
pyglialo.list_of_winners.append(name)
return redirect(url_for('saved'))
@app.route('/saved')
def saved():
name = pyglialo.list_of_winners[-1]
winner = {
'name': name
}
lead_text = 'Winner for slot {}'.format(len(pyglialo.list_of_winners))
return render_template('saved.html', winner=winner, winners=pyglialo.list_of_winners, lead_text=lead_text)
# FIXME: not working
"""
@app.route('/pass')
def pass_extraction():
pyglialo.list_of_winners.append('empty_slot')
lead_text = 'Slot {} is empty :('.format(len(pyglialo.list_of_winners))
return render_template('pass.html', winners=pyglialo.list_of_winners, lead_text=lead_text)
"""
@app.route('/finalize')
def finalize_the_goodies():
pyglialo.save_winners_list()
return render_template('finalize.html', winners=pyglialo.list_of_winners)
if __name__ == '__main__':
app.run(debug=True)