Skip to content

Instantly share code, notes, and snippets.

@cagerton
Created August 6, 2014 01:49
Show Gist options
  • Save cagerton/c4ba1d8cfbcad82861d7 to your computer and use it in GitHub Desktop.
Save cagerton/c4ba1d8cfbcad82861d7 to your computer and use it in GitHub Desktop.

Revisions

  1. cagerton renamed this gist Aug 6, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. cagerton created this gist Aug 6, 2014.
    38 changes: 38 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    from flask import Flask, redirect, render_template, url_for, request
    from flask_bootstrap import Bootstrap
    import redis
    import json

    app = Flask(__name__)
    Bootstrap(app)
    r = redis.Redis()


    @app.route("/")
    def home():
    count = r.llen("q")
    first = r.lindex("q", 0)
    if first:
    first = json.dumps(json.loads(first.decode()), indent=4)

    return render_template("home.html", count=count, first=first)


    @app.route("/pop", methods=["POST"])
    def pop():
    r.lpop("q")
    return redirect(url_for('home'))


    @app.route("/recv-hook", methods=["POST"])
    def recv_hook():
    keep = {'recipient', 'from', 'subject', 'timestamp', 'token', 'signature',}
    data = dict({(k, request.form.get(k, None)) for k in keep})
    data['keys'] = list(request.form.keys())
    dumped = json.dumps(data)
    r.rpush("q", dumped)
    return "Got it.", 200


    if __name__ == "__main__":
    app.run(debug=True)