Created
          August 6, 2014 01:49 
        
      - 
      
- 
        Save cagerton/c4ba1d8cfbcad82861d7 to your computer and use it in GitHub Desktop. 
Revisions
- 
        cagerton renamed this gist Aug 6, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        cagerton created this gist Aug 6, 2014 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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)