diff options
Diffstat (limited to 'compile.py')
-rwxr-xr-x | compile.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/compile.py b/compile.py new file mode 100755 index 0000000..28247eb --- /dev/null +++ b/compile.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +import httplib, urllib, sys + +# Define the parameters for the POST request and encode them in +# a URL-safe format. + +file = open(sys.argv[1]) +js_code = file.read() +file.close() + +params = urllib.urlencode([ + ('js_code', js_code), + ('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() +print data +conn.close() |