fix: empty listCadeau + can have yourself for the gift
This commit is contained in:
parent
f2d9c299a5
commit
0972d3714c
14
app.py
14
app.py
|
@ -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')
|
||||||
|
|
Loading…
Reference in a new issue