Created
August 20, 2012 21:38
-
-
Save starenka/3408133 to your computer and use it in GitHub Desktop.
shows full redirect path for given url
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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import urllib2 | |
| from flask import Flask | |
| import requests | |
| app = Flask(__name__) | |
| app.debug = False | |
| @app.route('/url=<path:uri>/') | |
| def show_redirects(uri): | |
| resp = requests.get(urllib2.unquote(uri).replace(':/', '://')) | |
| urls = [one.url for one in resp.history] + [resp.url] | |
| ret = '<html><head><link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet"></head><body>' | |
| ret += ''.join(map(lambda x: '<li><h2><a href="%s">%s</a><h2></li>' % (x,x), urls)) | |
| return '<div class="hero-unit"><ol>%s</ol></div></body></html>' % ret | |
| if __name__ == '__main__': | |
| app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment