-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
61 lines (47 loc) · 1.4 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
# -*- coding: utf-8 -*-
'''Entry point to all things to avoid circular imports.'''
import os
import random
from flask import Flask, render_template
sortedPicks = []
unsortedPicks = []
calculated = False
counter = 0
finished = True
names = ["Dave", "Ethan", "Evan", "Juan", "Kyle", "Malcolm", "Mamoon",
"Matt", "Moses", "Sam"]
picks = {}
app = Flask(__name__)
def picker():
def spin():
nums = [x for x in range(1, 11, 1)]
for i in range(0,len(nums)):
pick = random.choice(nums)
picks[names[i]] = pick
nums.remove(pick)
spin()
while picks["Malcolm"] > 3:
spin()
return picks
@app.route('/')
def doIt():
return render_template('button.html')
def runIt():
global sortedPicks, unsortedPicks, counter, finished
unsortedPicks = picker()
sortedPicks = sorted(picks.items(), key=lambda x: x[1])
counter = 0
finished = True
@app.route('/draft')
def addOne():
global sortedPicks, counter, calculated, finished
if calculated is False:
runIt()
calculated = True
counter += 1
if counter is len(names):
finished = False
return render_template('list.html', picks=sortedPicks[-counter:], showButton=finished)
if __name__ == '__main__':
# Threaded option to enable multiple instances for multiple user access support
app.run(threaded=True, port=5000)