/ Published in: Python
URL: http://bcmoney-mobiletv.com/blog/2009/05/01/the-server-side-proxy/
Source of inspiration for tiny code: http://coreygoldberg.blogspot.com/2008/09/python-vs-java-http-get-request.html
Python – Passing URL Parameters Variable To Python: http://erunways.com/python-passing-url-parameters-variable-to-python/
Expand |
Embed | Plain Text
#!/usr/bin/env python # -*- coding: UTF-8 -*- import cgitb import cgi import urllib cgitb.enable() params = cgi.FieldStorage() u = params.getvalue('url') f = params.getvalue('f') e = params.getvalue('e') if u is None: print "** ERROR **" elif len(u) == 0: url = "http://example.com" else: url = u if f is None: print "** ERROR **" elif len(f) == 0: format = "text/plain" else: format = f if e is None: print "** ERROR **" elif len(e) == 0: encoding = "utf-8" else: encoding = e print "Content-Type: "+format";charset="+encoding print urllib.urlopen(url).read()
You need to login to post a comment.
