add an url to this address to get a proxyfied response
example: http://proxpix.tshirtman.fr/http://s1.directupload.net/images/110909/wfm2q82v.png
#!/usr/bin/env python
from flask import Flask
from flask import make_response
from flask import request
from flask import escape
app = Flask(__name__)
import urllib2
import mimetypes
@app.route('/')
def main():
code = escape(open(__file__).read())
return '''
<!DOCTYPE html>
<html><head><title></title></head><body>
<h1>Usage</h1>
<p>
add an url to this address to get a proxyfied response<br/>
example: '''+request.base_url+'''http://s1.directupload.net/images/110909/wfm2q82v.png
</p>
<h1>About</h1>
Developped using <a href='http://python.org'>python</a> and the <a href='http://flask.pocoo.org'>flask</a> microframework.<br />
my <a href='/code'>source code</a> is:
<pre>''' + str(code) + '''
</pre>
(Yeah, most of the code is there so it's able to show its own code :])<br />
released in WTFPL
</body>
</html>
'''
@app.route('/<path:url>')
def proxy(url):
if not url.startswith('http://'):
url = 'http://'+url
r = make_response(urllib2.urlopen(url).read())
r.mimetype = mimetypes.guess_type(url)[0]
return r
@app.route('/code')
def code():
r = make_response(open(__file__).read())
r.mimetype = 'text/plain'
return r
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5001, debug=False)
(Yeah, most of the code is there so it's able to show its own code :])