from flask import Flask, request, render_template import random import myconfig app = Flask(__name__) listCadeau = {} def genCadeau(): global listCadeau tmp = list(myconfig.listGens.keys()) for g in myconfig.listGens.keys(): 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') def code(): code = request.args.get("code") a = myconfig.listGens.get(code, None) if a == None: return render_template("code.html", error=True) else: b = myconfig.listGens.get(listCadeau.get(code)) return render_template("code.html", a=a, b=b) if __name__ == "__main__": genCadeau() app.run()