#!/usr/bin/python import SOAPpy import Image from StringIO import StringIO import urllib import os destdir = "/home/web/brooks" destURL = "http://www.cs.usfca.edu/~brooks/" def rotate(url, degrees) : ## rotate the image im = Image.open(StringIO(urllib.urlopen(url).read())) newIm = im.rotate(degrees) ## get the filename index = url.rfind('/') fname = url[index+1:] base = url[:index] (prefix, extension) = fname.split('.') newname = prefix + "rotated" + "." + extension ## write the file. newIm.save(destdir + "/" + newname) os.chmod(destdir + "/" + newname, 0755) ## send back the URL return destURL + newname if __name__ == '__main__' : server = SOAPpy.SOAPServer(("localhost", 8080)) server.registerFunction(rotate) server.serve_forever()