Skip to content

Instantly share code, notes, and snippets.

@tspycher
Created December 19, 2017 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tspycher/f2ad5a9296baae42440a25db7d4bcc9e to your computer and use it in GitHub Desktop.
Save tspycher/f2ad5a9296baae42440a25db7d4bcc9e to your computer and use it in GitHub Desktop.
Queue-It.org Python Flask Example
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