def setup(self): router = HttpBin('/') return wsgi.WsgiHandler([ wsgi.clean_path_middleware, wsgi.cookies_middleware, wsgi.authorization_middleware, wsgi.MediaRouter('media', ASSET_DIR), ws.WebSocket('/graph-data', Graph()), router ])
def setup(self, environ): router = HttpBin('/') return wsgi.WsgiHandler([ ExpectFail('expect'), wsgi.wait_for_body_middleware, wsgi.clean_path_middleware, wsgi.authorization_middleware, wsgi.MediaRouter('media', ASSET_DIR, show_indexes=True), ws.WebSocket('/graph-data', Graph()), router ])
def setup(self, environ): '''Called once only to setup the WSGI application handler. Check :ref:`lazy wsgi handler <wsgi-lazy-handler>` section for further information. ''' cfg = environ['pulsar.cfg'] loop = environ['pulsar.connection']._loop self.store = data.create_store(cfg.data_store, loop=loop) pubsub = self.store.pubsub(protocol=WsProtocol()) channel = '%s_messages' % self.name pubsub.subscribe(channel) middleware = [wsgi.Router('/', get=self.home_page), ws.WebSocket('/message', PhilosopherWs(pubsub, channel)), wsgi.FileRouter('/favicon.ico', FAVICON), wsgi.MediaRouter('media', ASSET_DIR)] return wsgi.WsgiHandler(middleware)
def middleware(self, app): '''Add two middleware handlers if configured to do so.''' middleware = [] if app.config['CLEAN_URL']: middleware.append(wsgi.clean_path_middleware) if app.config['SERVE_STATIC_FILES']: icon = app.config['FAVICON'] if icon: middleware.append(FileRouter('/favicon.ico', icon)) path = app.config['MEDIA_URL'] # Check if node modules are available node_modules = os.path.join(os.path.dirname(app.meta.path), 'node_modules') if os.path.isdir(node_modules): node = '%snode_modules/' % path middleware.append(wsgi.MediaRouter(node, node_modules, show_indexes=app.debug)) middleware.append(MediaRouter(path, app.meta.media_dir, show_indexes=app.debug)) return middleware
def middleware(self, app): '''Add two middleware handlers if configured to do so.''' middleware = [] if app.config['CLEAN_URL']: middleware.append(wsgi.clean_path_middleware) path = app.config['MEDIA_URL'] if is_absolute_uri(path): app.config['SERVE_STATIC_FILES'] = False if os.path.isdir(app.config['SERVE_STATIC_FILES'] or ''): if path.endswith('/'): path = path[:-1] location = app.config['SERVE_STATIC_FILES'] middleware.append(wsgi.MediaRouter(path, location, show_indexes=app.debug)) if app.config['REDIRECTS']: for url, to in app.config['REDIRECTS'].items(): middleware.append(RedirectRouter(url, to)) return middleware
def setup(self, environ): return wsgi.WsgiHandler([ ws.WebSocket('/message', WsMail()), wsgi.MediaRouter('/media', ASSET_DIR), wsgi.Router('/', get=self.home) ])