fix: empty listCadeau + can have yourself for the gift
This commit is contained in:
parent
f2d9c299a5
commit
0972d3714c
1 changed files with 7 additions and 7 deletions
14
app.py
14
app.py
|
@ -8,18 +8,18 @@ app = Flask(__name__)
|
|||
listCadeau = {}
|
||||
|
||||
def genCadeau():
|
||||
global listCadeau
|
||||
tmp = list(myconfig.listGens.keys())
|
||||
for g in myconfig.listGens.keys():
|
||||
a, b = random.choices(tmp, k=2)
|
||||
if a == g:
|
||||
listCadeau[g] = b
|
||||
tmp.remove(b)
|
||||
else:
|
||||
listCadeau[g] = a
|
||||
tmp.remove(a)
|
||||
pc = [v for v in tmp if v != g]
|
||||
a = random.choice(pc)
|
||||
listCadeau[g] = a
|
||||
tmp.remove(a)
|
||||
|
||||
@app.route('/')
|
||||
def hello():
|
||||
if not listCadeau:
|
||||
genCadeau()
|
||||
return render_template("index.html")
|
||||
|
||||
@app.route('/code')
|
||||
|
|
Loading…
Reference in a new issue