#!/usr/bin/python

import httplib
import sys
import urllib
import os

def main(args):
  server = os.environ.get("REDUCISAURUS", "localhost:8080")

  params = urllib.urlencode({'file1': open(args.pop()).read()})
  headers = {'Content-Type': 'application/x-www-form-urlencoded'}
  conn = httplib.HTTPConnection(server)
  conn.request('POST', '/js', params, headers)
  response = conn.getresponse()
  print response.status, response.reason
  data = response.read()
  conn.close()
  print data
  print "\n"

if __name__ == "__main__":
  main(sys.argv)

@@ -12,16 +12,22 @@
 python%0A%0A
+try:%0A%09
 import h
@@ -37,19 +37,117 @@
 lib%0A
-import sys%0A
+except ImportError:%0A%09import http.client as httplib%0A%0Atry:%0A%09import urllib.parse as urllib%0Aexcept ImportError:%0A%09
 impo
@@ -155,16 +155,28 @@
 t urllib
+%0A%0Aimport sys
 %0Aimport 
@@ -195,16 +195,19 @@
 (args):%0A
+%0A
+  
   server
@@ -229,20 +229,14 @@
 et(%22
-REDUCISAURUS
+SERVER
 %22, %22
@@ -250,15 +250,243 @@
 st:8
-080
+888
 %22)%0A%0A
+    for arg in args:%0A        if arg.endswith('.js'):%0A            path = '/js'%0A        elif arg.endswith('.css'):%0A            path = '/css'%0A        else:%0A            print ('Invalid file type ' + arg)%0A            continue%0A%0A      
   pa
@@ -531,15 +531,8 @@
 (arg
-s.pop()
 ).re
@@ -538,16 +538,22 @@
 ead()%7D)%0A
+      
   header
@@ -610,16 +610,22 @@
 coded'%7D%0A
+      
   conn =
@@ -656,16 +656,22 @@
 server)%0A
+      
   conn.r
@@ -685,21 +685,20 @@
 'POST', 
-'/js'
+path
 , params
@@ -708,16 +708,22 @@
 eaders)%0A
+      
   respon
@@ -746,24 +746,30 @@
 ponse()%0A
+      
   print 
 response
@@ -760,16 +760,17 @@
   print 
+(
 response
@@ -793,17 +793,24 @@
 e.reason
-%0A
+)%0A      
   data =
@@ -826,16 +826,22 @@
 .read()%0A
+      
   conn.c
@@ -847,24 +847,30 @@
 close()%0A
+      
   print 
 data%0A  p
@@ -865,21 +865,29 @@
 int 
+(
 data
+)
 %0A
+      
   print 
 %22%5Cn%22
@@ -886,12 +886,14 @@
 int 
+(
 %22%5Cn%22
+)
 %0A%0Aif
@@ -932,10 +932,14 @@
 sys.argv
+%5B1:%5D
 )%0A

Update post.py to work with Python 3