def mount(conf): def CORS(): cherrypy.response.headers["Access-Control-Allow-Origin"] = os.environ['OPENSHIFT_APP_DNS'] cherrypy.config.update({"tools.staticdir.root": files.get_root()}) cherrypy.config.update(conf) cherrypy.tools.CORS = cherrypy.Tool('before_handler', CORS) cherrypy.tree.mount(wsgi.application(), "/", conf)
def test_get_ponies(self): expected_ponies = [[ "not-a-real-image.jpg", "check out this header", "Check out these words." ]] ponies_path = os.path.join(files.get_root(), 'test', 'resource', 'test-get-ponies-resource.xml') c = Carousel(ponies_path) ponies = c.get_ponies() self.assertIsInstance(ponies, [].__class__, "Get ponies did not return a list.") self.assertListEqual( expected_ponies, ponies, "List {0} did not match expected list {1}".format( ponies, expected_ponies))
def index(self): resource = open(os.path.join(files.get_root(), "index.html"), 'r') response_body = resource.read() return response_body
def get_ponies(self): ponies_path = os.path.join(files.get_root(), 'lib', 'resource', 'carousel.xml') c = carousel.Carousel(ponies_path) return json.dumps(c.get_ponies())
try: execfile(virtualenv, dict(__file__=virtualenv)) except IOError: pass import cherrypy import wsgi def mount(conf): def CORS(): cherrypy.response.headers["Access-Control-Allow-Origin"] = os.environ['OPENSHIFT_APP_DNS'] cherrypy.config.update({"tools.staticdir.root": files.get_root()}) cherrypy.config.update(conf) cherrypy.tools.CORS = cherrypy.Tool('before_handler', CORS) cherrypy.tree.mount(wsgi.application(), "/", conf) def start(): cherrypy.engine.start() cherrypy.engine.block() def end(): cherrypy.engine.exit() if __name__ == "__main__": mount(os.path.join(files.get_root(), "conf", "server.conf")) start()
def setup_server(): app.mount(os.path.join(files.get_root(), "test", "test.server.conf"))