def main(global_configuration, **settings): configurator = config.Configurator( root_factory='mk.resources.RootResource', settings=settings, ) configurator.scan() return configurator.make_wsgi_app()
def __init__(self, server_address): super().__init__() self.server_address = server_address configurator = config.Configurator() self.configure(configurator) app = configurator.make_wsgi_app() self.server = simple_server.make_server(self.server_address[0], self.server_address[1], app) self.server_port = self.server.server_port self.socket = self.server.socket
def main(): cfg = config.Configurator(settings={ 'sqlalchemy.url': 'sqlite://', 'mako.directories': [ 'clld:web/templates', 'clld_cognacy_plugin:templates' ]}) cfg.include('clld.web.app') cfg.include('clld_cognacy_plugin') return cfg.make_wsgi_app()
import json from pyramid import config, response POSTS = [ "Just chillin'", "Writing code", "Being awesome", ] def posts(request): body = json.dumps(POSTS).encode('utf-8') return response.Response( content_type='application/json', body=body) def add_post(request): POSTS.append(request.json_body['content']) return response.Response('ok') with config.Configurator() as cfg: cfg.add_route('posts', '/posts', request_method='GET') cfg.add_view(posts, route_name='posts') cfg.add_route('add_post', '/posts', request_method='POST') cfg.add_view(add_post, route_name='add_post') app = cfg.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ c = config.Configurator(settings=settings) includeme(c) return c.make_wsgi_app()
values['max_jobs'] = int(max_jobs) values['queued'] = queued values['complete'] = complete values['active'] = running + queued values['total'] = running + queued + complete values['queue_time'] = _format_time(queue_time) values['queue_name'] = queue_name values['job_red'] = RED values['job_green'] = GREEN values['job_blue'] = BLUE values['filter_text'] = filter_text return t, values @view.view_config(route_name='zuul_status') def zuul_status(request): template, params = process_request(request) return response.Response(template.render(**params)) if __name__ == '__main__': conf = config.Configurator() conf.add_route('zuul_status', '/') conf.scan() app = conf.make_wsgi_app() ip = os.environ['OPENSHIFT_PYTHON_IP'] port = int(os.environ['OPENSHIFT_PYTHON_PORT']) server = make_server(ip, port, app) server.serve_forever()