from twisted.application import service from twisted.application import internet from twisted.web import server from twisted.web import resource from twisted.web import static # urls will look like # http://localhost:8080/theInputFileName.pdf?r=96&o=outputFile.jpg class Simple(resource.Resource): def getChild(self, name, request): inputfile = name resolution = int(request.args.get('r', ['72'])[0]) outputfile = request.args.get('o', [None])[0] if outputfile is None: outputfile = mktmp() #doTheTransformationSavingInOutputFile() return static.File(outputfile, 'image/jpeg') root = Simple() application = service.Application("simplest") internet.TCPServer(8080, server.Site(root)).setServiceParent(application)