-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello.py
66 lines (44 loc) · 1.39 KB
/
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
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
from flask import Flask, request, render_template, jsonify, Response
import backend
import ast
app = Flask(__name__)
app.config['TEMPLATES_AUTO_RELOAD'] = True
class Storage(object):
def __init__(self):
self.stack = []
def push(self, item):
self.stack.append(item)
def reset(self):
self.stack = []
put_team = Storage()
@app.route('/')
def my_form():
put_team.reset()
return render_template('index.html')
@app.route('/', methods=['POST'])
def my_form_post():
teams = request.form.getlist('teams')
teams = teams[0]
teams = ast.literal_eval(teams)
teams.pop(0)
put_team.push(teams)
return jsonify(result={'status': 200})
@app.route('/teams')
def team_sender():
set_team = put_team.stack[0]
put_team.reset()
groups = [team for team in backend.get_team_groups(set_team, 4)]
put_team.push(groups)
return render_template('teams.html', groups=groups)
@app.route('/end')
def get_csv():
return render_template('end.html')
@app.route('/summary')
def get_structure():
csv_groups = put_team.stack[0]
put_team.reset()
excel = backend.csv_data(csv_groups)
excel = backend.get_data_structure(excel)
return Response(excel.to_csv(index=False, header=False), mimetype="text/csv", headers={"Content-disposition": "attachment; filename=PUT-table_group.csv"})
if __name__ == '__main__':
app.run(debug=True)