def flush(): vr.flush_redis_db() vr.vote_init(POLL, POLL_OPTIONS) return "Flushed redis DB"
if request.method == 'POST': vote_for = request.form['vote_option'].lower() vr.cast_vote(POLL, vote_for) pv = vr.last_vote(POLL) pv_num = 0 if pv: pv_num = vr.get_votes(POLL, pv) poll_opts = sorted(vr.get_poll_options(POLL)) poll_values = [vr.get_votes(POLL, option) for option in poll_opts] return render_template('index.html', hostname=HOSTNAME, poll_name=POLL, vote_opts=get_vote_options(POLL_OPTIONS), previous_vote=pv, previous_vote_num=pv_num, poll_opts=json.dumps(poll_opts), poll_values=json.dumps(poll_values)) @app.route("/flushdb", methods=['GET']) def flush(): vr.flush_redis_db() vr.vote_init(POLL, POLL_OPTIONS) return "Flushed redis DB" if __name__ == '__main__': vr.vote_init(POLL, POLL_OPTIONS) app.run(host='0.0.0.0', port=5000, debug=True, threaded=True)