Skip to content

Instantly share code, notes, and snippets.

@joemccann
Created September 1, 2010 17:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemccann/561034 to your computer and use it in GitHub Desktop.
Save joemccann/561034 to your computer and use it in GitHub Desktop.
#!/usr/bin/python2.4
import httplib, urllib, sys
# ('code_url', sys.argv[1]) if we wanted to actually pass in a value from command line -> say u wanted to compress a different file...
params = urllib.urlencode([
('code_url', 'http://github.com/getify/LABjs/raw/master/LAB.src.js'),
('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
('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()
conn.close
filename = 'labjs.compiled.js'
print "\nWriting to file: %s\n" % filename
file = open(filename, 'w')
file.write(data)
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment