Skip to content

Commit

Permalink
added random partners
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh H committed Sep 18, 2018
1 parent 0aad280 commit 12317c8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python3

from flask import Flask, request, jsonify, send_file
import random

app = Flask(__name__)

Expand All @@ -13,6 +14,7 @@ def index():
index_file = 'www/index.html'
return send_file(index_file)


@app.route('/scripts.js')
def js():
js_file = 'www/scripts.js'
Expand Down Expand Up @@ -73,6 +75,29 @@ def checkoff_queue_manager():

return jsonify({'error_code': 400, 'message': msg})


@app.route('/partners', methods=['GET'])
def get_random_pair():
with open('roster.txt') as f:
roster = f.read()

people = roster.split('\n')
names = []
for p in people:
names.append(p.split(',')[0].strip())

if len(names) % 2 != 0:
names.append('')

random.shuffle(names)

pairs = ''
for i in range(0, len(names), 2):
pairs += "<h1>" + names[i] + ", " + names[i+1] + "</h1>"

return pairs


if __name__ == "__main__":
port = 5000
app.run(host='0.0.0.0', port=port)

0 comments on commit 12317c8

Please sign in to comment.