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

14
app.py
View file

@ -8,18 +8,18 @@ app = Flask(__name__)
listCadeau = {} listCadeau = {}
def genCadeau(): def genCadeau():
global listCadeau
tmp = list(myconfig.listGens.keys()) tmp = list(myconfig.listGens.keys())
for g in myconfig.listGens.keys(): for g in myconfig.listGens.keys():
a, b = random.choices(tmp, k=2) pc = [v for v in tmp if v != g]
if a == g: a = random.choice(pc)
listCadeau[g] = b listCadeau[g] = a
tmp.remove(b) tmp.remove(a)
else:
listCadeau[g] = a
tmp.remove(a)
@app.route('/') @app.route('/')
def hello(): def hello():
if not listCadeau:
genCadeau()
return render_template("index.html") return render_template("index.html")
@app.route('/code') @app.route('/code')