ebu/PlugIt

Redirect to another page

Closed this issue · 1 comments

Example:

@action(route="/vote/<int:pollId>/<int:responseId>", template="vote.html")
@only_logged_user()
@user_info(props=['username'])
def vote(request, pollId, responseId):
    """Vote for a poll"""

    username = request.args.get('ebuio_u_username')

    # Remove old votes from the same user on the same poll
    curDB.execute('DELETE FROM Vote WHERE username = ?  AND responseId IN (SELECT id FROM Response WHERE pollId = ?) ', (username, pollId))

    # Save the vote
    curDB.execute('INSERT INTO Vote (username, responseID) VALUES (?, ?) ', (username, responseId))

    coxDB.commit()

    return {'id': pollId}

Instead of displaying the template vote.html at the end the operation, is it possible to send a redirect to the home page?


Since we would like to keep the Flask Server as an API, it should appear in meta or in a "special template". What do you think?

Done !