Created
August 6, 2014 01:49
-
-
Save cagerton/c4ba1d8cfbcad82861d7 to your computer and use it in GitHub Desktop.
this saves 3 months of vpn setup
This 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 characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment