import sys from wsgiref.simple_server import make_server EMPLOYEES_XML = """\ Bob Costas Bob Sagat Harbor Oaks Oak Barrel Sag Harbor """ EMPLOYEES_XML_LEN = str(len(EMPLOYEES_XML)) CROSSDOMAIN_XML = """\ """ CROSSDOMAIN_XML_LEN = str(len(CROSSDOMAIN_XML)) def main(sysargs=sys.argv[:]): server = make_server('0.0.0.0', 18080, employees_app) server.serve_forever() return 0 def employees_app(environ, start_response): path_info = environ.get('PATH_INFO', '/').strip(' /') if path_info == 'employees.xml': start_response('200 OK', [ ('content-type', 'text/xml'), ('content-length', EMPLOYEES_XML_LEN), ]) return [EMPLOYEES_XML] elif path_info == 'crossdomain.xml': start_response('200 OK', [ ('content-type', 'text/xml'), ('content-length', CROSSDOMAIN_XML_LEN), ]) return [CROSSDOMAIN_XML] else: start_response('404 Not Found', [('content-type', 'text/plain')]) return ['sorry charlie'] if __name__ == '__main__': sys.exit(main()) # vim:filetype=python