Created
January 22, 2012 07:39
-
-
Save lazypower/1656111 to your computer and use it in GitHub Desktop.
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/python2.4 | |
import httplib, urllib, sys | |
# Define the parameters for the POST request and encode them in | |
# a URL-safe format. | |
params = urllib.urlencode([ | |
('js_code', open(sys.argv[1], 'r').read()), | |
('compilation_level', 'WHITESPACE_ONLY'), | |
('output_format', 'text'), | |
('output_info', 'compiled_code'), | |
]) | |
# Always use the following value for the Content-type header. | |
headers = { "Content-type": "application/x-www-form-urlencoded" } | |
conn = httplib.HTTPConnection('closure-compiler.appspot.com') | |
conn.request('POST', '/compile', params, headers) | |
response = conn.getresponse() | |
data = response.read() | |
print data | |
conn.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment