fix: empty listCadeau + can have yourself for the gift

This commit is contained in:
rick 2021-12-11 03:12:47 +01:00
parent f2d9c299a5
commit 0972d3714c
Signed by: Rick
GPG Key ID: 2B593F087240EE99
1 changed files with 7 additions and 7 deletions

14
app.py
View File

@ -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')