Created
December 19, 2017 13:02
-
-
Save tspycher/f2ad5a9296baae42440a25db7d4bcc9e to your computer and use it in GitHub Desktop.
Queue-It.org Python Flask Example
This file contains 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, request | |
import hashlib | |
import re | |
app = Flask(__name__) | |
# plays best with ngrok proxy server https://ngrok.com/ | |
@app.route("/") | |
def hello(): | |
queue_url = "https://DOMAIN.queue-it.net/?c=COMAPNY&e=playground" | |
secret = "yourAwesomeSecret" | |
if request.args.has_key('q'): | |
url = re.sub("http://", "https://", re.search("^.*&h=", request.url).group(0)) | |
expected_hash = hashlib.md5("%s%s" % (url, secret)).hexdigest() | |
if expected_hash == request.args.get('h', "---"): | |
return "<strong>Welcome!!!</strong></br></br>URL orig: %s</br>URL translated: %s</br>X: %s</br>H: %s" % (request.url, url, expected_hash,request.args.get('h', "---")) | |
# redirected from queue it | |
return "ERROR!!!</br>URL orig: %s</br>URL translated: %s</br>X: %s</br>H: %s" % (request.url, url, expected_hash,request.args.get('h', "---")) | |
return redirect(queue_url, 302) | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment