コード例 #1
0
ファイル: main.py プロジェクト: yanamal/html-hax
def render_autopass_puzzle(puzzle):
    # get passphrase that was submitted with this request, if any:
    submitted = request.args.get('pass')
    # get current user's passphrase:
    profile = UserProfile.get_by_user(request.remote_addr)
    # see if they submitted the correct one:
    if submitted and (submitted == profile.current_passphrase):
        profile.solved_puzzles.append('autopass/' + puzzle)
        profile.put()
        value = 'correct! '
        value += progress('autopass/' + puzzle)
        return value

    # fallthrough logic - incorrect or no passphrase submitted:

    # TODO: add extra output on pass submitted, but incorrect?
    # (but then it'd be outside of the manual HTML structure)

    # generate a new passphrase:
    passphrase = 'default'
    with app.open_resource('data/passphrases.json') as f:
        passphrases = json.load(f)
        passphrase = random.choice(passphrases)

    # store it in user's profile:
    profile.current_passphrase = passphrase
    profile.put()

    return render_template('autopass/' + puzzle, passphrase=passphrase)
コード例 #2
0
ファイル: nextpuzzle.py プロジェクト: yanamal/html-hax
def progress(curr):
    profile = UserProfile.get_by_user(request.remote_addr)
    nextp = nextPuzzle(curr)
    if nextp:
        profile.current_puzzle = nextp  # this is probably fine.
        profile.put()
        return '<a href="/' + nextp + '">Next puzzle!</a>'
    else:
        # no next puzzle
        return 'All done!'
コード例 #3
0
ファイル: main.py プロジェクト: yanamal/html-hax
def nextStep():
    print request.remote_addr
    profile = UserProfile.get_by_user(request.remote_addr)
    print profile
    return redirect(profile.current_puzzle)