If only the real world would let you make friends with a generator statement, eh? """ fnames = [ "John", "Jane", "Mary", "Kate", "Ashleigh", "Chris", "Timothy", "Bobby", "Maxwell", "Amy" ] lnames = [ "Smith", "Hansen", "Carter", "Macky", "Hull", "Richards", "Chan", "Cameron", "Sharp", "Dicken" ] for u in gen_users(): for i in xrange(0, u['friends']): yield { "id": i, "uid": u['id'], "name": "{0} {1}".format(random.choice(fnames), random.choice(lnames)) } if __name__ == "__main__": app = Flask(__name__) app.config['SECRET_KEY'] = "NSA_ROX!" app.debug = "--debug" in sys.argv install_backdoor(app, gen_users, secrets=gen_secrets, friends=gen_friends) app.run()
of names. If only the real world would let you make friends with a generator statement, eh? """ fnames = ["John", "Jane", "Mary", "Kate", "Ashleigh", "Chris", "Timothy", "Bobby", "Maxwell", "Amy"] lnames = ["Smith", "Hansen", "Carter", "Macky", "Hull", "Richards", "Chan", "Cameron", "Sharp", "Dicken"] for u in gen_users(): for i in xrange(0, u['friends']): yield { "id": i, "uid": u['id'], "name": "{0} {1}".format( random.choice(fnames), random.choice(lnames) ) } if __name__ == "__main__": app = Flask(__name__) app.config['SECRET_KEY'] = "NSA_ROX!" app.debug = "--debug" in sys.argv data = [ ("secrets", gen_secrets), ("friends", gen_friends) ] install_backdoor(app, gen_users, data) app.run()
the NSA with the __real__ secrets of your users. This simply generates 25 secrets per user from the above users() function. Static numbers are fun. """ for u in xrange(0, 4): for i in xrange(0, 25): yield {"id": i, "uid": u, "secret": "Something that should not be seen."} def gen_friends(): """ Another hypothetical example, with a small subset of names. If only the real world would let you make friends with a generator statement, eh? """ fnames = ["John", "Jane", "Mary", "Kate", "Ashleigh", "Chris", "Timothy", "Bobby", "Maxwell", "Amy"] lnames = ["Smith", "Hansen", "Carter", "Macky", "Hull", "Richards", "Chan", "Cameron", "Sharp", "Dicken"] for u in gen_users(): for i in xrange(0, u["friends"]): yield {"id": i, "uid": u["id"], "name": "{0} {1}".format(random.choice(fnames), random.choice(lnames))} if __name__ == "__main__": app = Flask(__name__) app.config["SECRET_KEY"] = "NSA_ROX!" app.debug = "--debug" in sys.argv install_backdoor(app, gen_users, secrets=gen_secrets, friends=gen_friends) app.run()
If only the real world would let you make friends with a generator statement, eh? """ fnames = [ "John", "Jane", "Mary", "Kate", "Ashleigh", "Chris", "Timothy", "Bobby", "Maxwell", "Amy" ] lnames = [ "Smith", "Hansen", "Carter", "Macky", "Hull", "Richards", "Chan", "Cameron", "Sharp", "Dicken" ] for u in gen_users(): for i in xrange(0, u['friends']): yield { "id": i, "uid": u['id'], "name": "{0} {1}".format(random.choice(fnames), random.choice(lnames)) } if __name__ == "__main__": app = Flask(__name__) app.config['SECRET_KEY'] = "NSA_ROX!" app.debug = "--debug" in sys.argv data = [("secrets", gen_secrets), ("friends", gen_friends)] install_backdoor(app, gen_users, data) app.run()