Example #1
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')
        environ['nicknames'] = []

        if not path:
            start_response('200 OK', [('Content-Type', 'text/html')])
            return ['<h1>Welcome. '
                'Try the <a href="/chat.html">chat</a> example.</h1>']

        if path in ['socket.io.js', 'chat.html', 'stylesheets/style.css']:
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'': ChatNamespace})
        else:
            return not_found(start_response)
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if path.startswith('socket.io'):
            socketio_manage(environ, namespaces)
        else:
            return not_found(start_response)
Example #3
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if not path:
            start_response('200 OK', [('Content-Type', 'text/html')])
            data = open('index.html')
            return data

        if path.startswith('static/') or path == 'index.html':
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/game': GameNamespace}, self.request)
        else:
            return not_found(start_response)
Example #4
0
def stream(remaining):
    try:
        socketio_manage(request.environ, {'/stream': StreamNamespace}, request)
    except:
        logger.error("Exception while handling socketio connection", exc_info=True)

    return Response()
Example #5
0
def view_socketio(path):
    socketio_manage(request.environ, {
        "/identity": identity.IdentityNamespace,
        "/campaign": campaign.CampaignNamespace,
        },
        request=current_app._get_current_object(),
        )
Example #6
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        #if path.startswith('static/') or path == 'index.html' or path == 'admin.html':
        if path.startswith('static/') or path.endswith('.html'):
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith('.js'):
                content_type = 'text/javascript'
            elif path.endswith('.css'):
                content_type = 'text/css'
            elif path.endswith('.swf'):
                content_type = 'application/x-shockwave-flash'
            else:
                content_type = 'text/html'

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith('socket.io'):
            socketio_manage(environ, {'/cloud': CloudNamespace})
        else:
            return not_found(start_response)
Example #7
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/') or 'index.html'

        if path.startswith('static/') or path == 'index.html':
            try:
                data = open('../www/' + path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".png"):
                content_type = "image/png"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/pop': PopNamespace})
        else:
            return not_found(start_response)
Example #8
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/') or 'index.html'

        if path.startswith('static/') or path == 'index.html':
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/value': ValueNamespace})
        else:
            return not_found(start_response)
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if path.startswith('socket.io'):
            socketio_manage(environ, namespaces)
        else:
            return not_found(start_response)
Example #10
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/') or 'index.html'

        if (path.startswith('static/') or path == 'index.html'
                or path == 'gif.html'):
            try:
                data = open(os.path.join(INTERFACE_FOLDER, path)).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/mindflex': BaseNamespace})
            print 'socketio ready'
        else:
            return not_found(start_response)
Example #11
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/') or 'index.html'

        if path.startswith('static/') or path == 'index.html':
            try:
                data = (open(path).read().replace(
                    "https://maps.googleapis.com/maps/api/js?key=API_KEY",
                    "https://maps.googleapis.com/maps/api/js"))

            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/nupic': NupicNamespace})
        else:
            return not_found(start_response)
Example #12
0
def application(env, start_response):
    """ Our web serving app """
    path = env['PATH_INFO'].strip('/') or 'index.html'

    # static stuff
    if path.startswith('static/') or path == "index.html":
        try:
            data = open(path).read()
        except Exception:
            return http404(start_response)

        if path.endswith(".js"):
            content_type = "text/javascript"
        elif path.endswith(".css"):
            content_type = "text/css"
        elif path.endswith(".png"):
            content_type = "image/png"
        elif path.endswith(".swf"):
            content_type = "application/x-shockwave-flash"
        else:
            content_type = "text/html"

        start_response('200 OK', [('Content-Type', content_type)])
        return [data]

    # socketIO request
    if path.startswith('socket.io/'):
        socketio_manage(env, {'': LogStreamNS})
    else:
        return http404(start_response)
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if not path:
            start_response('200 OK', [('Content-Type', 'text/html')])
            return ["okokokok"]

        if path.startswith("lib/") or path.startswith(
                "images/") or path.startswith(
                    "client/") or path == "style.css" or path == "index.html":
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".png"):
                content_type = "image/png"
            elif path.endswith(".css"):
                content_type = "text/css"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'': MultiPlayerNamespace})
        else:
            return notFound(start_response)
Example #14
0
 def __call__(self, environ, start_response):
     path = environ['PATH_INFO'].strip('/')
     if path is not None and path.startswith('socket.io'):
         socketio_manage(environ, self.socket.get_namespaces(), self.app,
                         json_loads=json.loads, json_dumps=json.dumps)
     else:
         return self.wsgi_app(environ, start_response)
Example #15
0
    def dispatch_request(self, urls, request):
        """Dispatch the incoming *request* to the given view function or class.

        If the "request" is a socket.io message, route it to the registered
        namespace.

        :param urls: The URLs parsed by binding the URL map to the environment.
        :param request: The current HTTP request.
        :type request :class:`werkzeug.Request`:
        """
        if request.path.startswith('/socket.io'):
            try:
                socketio_manage(request.environ, self._namespaces, request)
            except:
                print("Exception while handling socketio connection")
            return Response()
        else:
            response = urls.dispatch(
                lambda e, v: self._routes[e](
                    request, **v))
            if isinstance(response, (unicode, str)):
                headers = {'Content-type': 'text/html'}
                response = Response(response, headers=headers)
            if not response:
                headers = {'Content-type': 'text/html'}
                response = Response('404 Not Found', headers=headers)
                response.status_code = 404
            return response
Example #16
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/') or 'index.html'

        if path.startswith('/static') or path == 'index.html':
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]
        if path.startswith("socket.io"):
            environ['scan_ts'] = self.scan_ts
            environ['scan_interval'] = self.scan_interval
            cur_ts = datetime.utcnow()
            socketio_manage(environ, {'/services': ServicesNamespace,
                                      '/sysinfo': SysinfoNamespace,
                                      '/cpu-widget': CPUWidgetNamespace,
                                      '/memory-widget': MemoryWidgetNamespace,
                                      '/network-widget': NetworkWidgetNamespace,
                                      '/disk-widget': DisksWidgetNamespace,
            })
            if ((cur_ts - self.scan_ts).total_seconds() > self.scan_interval):
                self.scan_ts = cur_ts
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if path.startswith(WithSocketIO.resource):
            socketio_manage(environ, collect_namespaces())
        else:
            return self.app(environ, start_response)
Example #18
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/') or 'index.html'

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/events': EventsNamespace})
        else:
            return not_found(start_response)
Example #19
0
def socketio(request):
    socketio_manage(request.environ, {
        '/chat': ChatNamespace,
    },
                    request=request)

    return HttpResponse()
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/') or 'index.html'

        if path.startswith('/static') or path == 'index.html':
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]
        if path.startswith("socket.io"):
            environ['scan_ts'] = self.scan_ts
            environ['scan_interval'] = self.scan_interval
            cur_ts = datetime.utcnow()
            socketio_manage(environ, {'/services': ServicesNamespace,
                                      '/sysinfo': SysinfoNamespace,
                                      '/cpu-widget': CPUWidgetNamespace,
                                      '/memory-widget': MemoryWidgetNamespace,
                                      '/network-widget': NetworkWidgetNamespace,
                                      '/disk-widget': DisksWidgetNamespace,
            })
            if ((cur_ts - self.scan_ts).total_seconds() > self.scan_interval):
                self.scan_ts = cur_ts
def handle_socketio(remaining):
    """Socket.IO route"""
    try:
        socketio_manage(request.environ, {'/alarmdecoder': DecoderNamespace}, { "alarmdecoder": g.alarmdecoder, "request": request})

    except Exception, err:
        current_app.logger.error("Exception while handling socketio connection", exc_info=True)
Example #22
0
    def socketio_route_handler(url_path):

        # FIXME: rm if unused
        if None == request.environ.get('socketio'):  # attempt ws upgrade process for non socketio clients
            header__upgrade = request.headers.get('Upgrade')
            if 'websocket' == header__upgrade:

                resp = make_response__http__empty(101)  # 'switching protocols' HTTP status code
                resp.headers['Upgrade'] = 'websocket'
                resp.headers['Connection'] = 'Upgrade'

                rmt_addr, rmt_port = request.req_probe__sock_addr.probe_client_socket_addr__ws_conn(request.environ)
                log.debug('ws: \'Upgrade: websocket\' header detected, serving \'101\': remote-socket-addr: %s:%s' % (rmt_addr, rmt_port))

                return resp
            else:
                raise Exception('ws: failed to obtain socketio object from WSGI environment')

        # init websocket-env
        ws_req_env = WS_Req_Env()
        ws_req_env.kernel = kernel
        ws_req_env.peer_sock_addr = ws_srv.req_probe__sock_addr.probe_client_socket_addr__ws_conn(request.environ)

        try:
            socketio_manage(request.environ, {'/graph': WebSocket_Graph_NS}, ws_req_env)  # connect socketio manager
            return make_response__json(status=HTTP_STATUS__200_OK)
        except:
            log.exception("ws: exception while handling connection", exc_info=True)
            return make_response__json(status=HTTP_STATUS__500_INTERNAL_SERVER_ERROR)
Example #23
0
def socketio(remaining):
    try:
        socketio_manage(request.environ, {'/chat': ChatNamespace}, request)
    except:
        application.logger.error('Exception handling sockets', exc_info=True)

    return Response()
Example #24
0
def socketio(remaining):
    try:
        socketio_manage(request.environ, {'/chat': ChatNamespace}, request)
    except:
        app.logger.error("Exception while handling socketio connection",
                         exc_info=True)
    return Response()
Example #25
0
 def __call__(self, environ, start_response):
     """
     WSGI application handler.
     """
     authorized = self.authorized(environ)
     path = environ["PATH_INFO"]
     if path.startswith("/socket.io/") and authorized:
         socketio_manage(environ, {"": IRCNamespace})
         return
     if not authorized:
         dispatch = self.respond_unauthorized
     elif path.startswith("/webhook/"):
         dispatch = self.respond_webhook
     elif self.django:
         dispatch = self.respond_django
     else:
         dispatch = self.respond_static
     response = dispatch(environ)
     if isinstance(response, int):
         response = (response, [], None)
     elif isinstance(response, basestring):
         response = (200, [], response)
     status, headers, content = response
     status_text = HTTP_STATUS_TEXT.get(status, "")
     headers.append(("Server", settings.GNOTTY_VERSION_STRING))
     start_response("%s %s" % (status, status_text), headers)
     if content is None:
         if status == 200:
             content = ""
         else:
             content = "<h1>%s</h1>" % status_text.title()
     return [content]
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if not path:
            start_response('200 OK', [('Content-Type', 'text/html')])
            return ['<h1>Welcome. ''Try the <a href="/index.html">guilbep</a> example.</h1>']

        if path.startswith('css/') or path.startswith('img/') or path.startswith('js/') or path.startswith('lib/') or path.startswith('partials/') or path == 'index.html':
            try:
                print path
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/pointer': PointerNamespace}, self.request)
        else:
            return not_found(start_response)
Example #27
0
    def __call__(self, environ, start_response):
        path = '/home/ele/workspace/Django/iot-dashboard/iotdashboard/templates/back/graph/graph.html'
        # print(path)
        # # print "***"

        try:
            # # print "+++"
            data = open(path).read()
            # # print data
            # # print "+++"
        except Exception:
            return not_found(start_response)

        if path.endswith(".js"):
            content_type = "text/javascript"
        elif path.endswith(".css"):
            content_type = "text/css"
        elif path.endswith(".swf"):
            content_type = "application/x-shockwave-flash"
        else:
            content_type = "text/html"

        start_response('200 OK', [('Content-Type', content_type)])
        return [data]

        # if path.startswith("socket.io"):
        socketio_manage(environ, {'/cpu': CPUNamespace})
Example #28
0
def socketio(remaining):
    try:
        socketio_manage(request.environ, {'': SessionNamespace}, dict(slug=request.args.get('slug')))
    except:
        app.logger.error("Exception while handling socketio connection", exc_info=True)

    return Response()
Example #29
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/') or 'index.html'

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/events': EventsNamespace})
        else:
            return not_found(start_response)
def stream(remaining):
    try:
        socketio_manage(request.environ, {'/stream': StreamNamespace}, request)
    except:
        logger.error("Exception while handling socketio connection", exc_info=True)

    return Response()
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if not path:
            start_response('200 OK', [('Content-Type', 'text/html')])
            return ['<h1>Welcome. '
                'Try the <a href="/control.html">control</a> example.</h1>']

        if path.startswith('static/') or path == 'socketio-web.html' or path == 'websocket-web.html':
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'': CarControlServer}, self.request)
        else:
            return not_found(start_response)
Example #32
0
def serve_request(environ, start_response):
        path = environ['PATH_INFO'].strip('/')
        if not path:
            start_response('200 OK', [('Content-Type', 'text/html')])
            return ['<h1>Welcome. '
                'Try the <a href="/chat.html">chat</a> example.</h1>']

        if path == 'chat.html':
            html = """
<!DOCTYPE html >
<html><head>
   <script src="https://qms.iulysses.com/static/js/libs/socket.io-0.9.6.min.js"></script>
   <script src="https://code.jquery.com/jquery-2.1.4.min.js" ></script>
</head>
<body>
<h1>I Love to WebSocket</h1>
<p id="content">
</p>
<p>
Open the javascript console to chat...
</p>
</body>
</html>
"""
            start_response('200 OK', [('Content-Type', "text/html")])
            return [html]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/chat': ChatNamespace}, {})
        else:
            return not_found(start_response)
Example #33
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        # print environ
        if not path:
            path = 'index.html'

        if path.startswith('static/') or path.endswith('html') or path.endswith('js'):
            try:
                data = open(path).read()
            except Exception:
                print 'Open path exception'
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'': OrbitSocket}, self.request)
        else:
            return not_found(start_response)
Example #34
0
def chat(environ, start_response):
    if environ['PATH_INFO'].startswith('/socket.io'):
        #       return socketio_manage(environ, { '/chat': AquetiNamespace })
        socketio_manage(environ, {'': AquetiNamespace})

    else:
        return serve_file(environ, start_response)
Example #35
0
def socketio(request):
    socketio_manage(request.environ,
        {
            '': ChatNamespace,
        }, request=request
    )
    return HttpResponse()
Example #36
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if not path:
            try:
                data = open('chat.html').read()
            except Exception:
                return not_found(start_response)

            start_response('200 OK', [('Content-Type', 'text/html')])
            return [data]


        if path.startswith('static/'):
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            #pdb.set_trace()
            socketio_manage(environ, {'': ChatNamespace}, self.request)
        else:
            return not_found(start_response)
Example #37
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if not path:
            start_response('200 OK', [('Content-Type', 'text/html')])
            return ['<h1>Welcome. '
                    'Try the <a href="/chat.html">chat</a> example.</h1>']

        root = os.path.dirname(__file__)
        if path.startswith('static/') or path == 'chat.html':
            path = os.path.join(root, path)
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'': ChatNamespace}, self.request)
        else:
            return not_found(start_response)
Example #38
0
def push_stream(rest):
    try:
        socketio_manage(request.environ, {"/game": GamesNamespace}, request)
    except:
        app.logger.error("Exception while handling socketio connection",
                         exc_info=True)
    return Response()
Example #39
0
def socket(remaining):
    try:
        socketio_manage(request.environ, {'/chat': SocketNS}, request)
    except:
        app.logger.error('Socket error', exc_info = True)

    return Response()
Example #40
0
def socketio(remaining):
    try:
        socketio_manage(request.environ, {'/ws': VimFoxNamespace}, request)
    except:
        app.logger.error("Socket Error.", exc_info=True)

    return Response()
Example #41
0
    def __call__(self, environ, start_response):
        path = environ["PATH_INFO"].strip("/")

        if not path:
            start_response("200 OK", [("Content-Type", "text/html")])
            return ["<h1>Welcome. " 'Try the <a href="/chat.html">chat</a> example.</h1>']

        if path.startswith("static/") or path == "chat.html":
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response("200 OK", [("Content-Type", content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {"": ChatNamespace}, self.request)
        else:
            return not_found(start_response)
Example #42
0
def socketio(request):
    socketio_manage(
        request.environ,
        {'': RandomNamespace},
        request=request
    )
    return http.HttpResponse()
Example #43
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/') or 'index.html'

        if path.startswith('static/') or path == 'index.html':
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'/sys_stat': SystemStatNamespace(self.FILE_DATA)})

        else:
            return not_found(start_response)
Example #44
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        if not path:
            start_response('200 OK', [('Content-Type', 'text/html')])
            return [
                '<h1>Welcome. '
                'Try the <a href="/todo.html">todo</a> example.</h1>'
            ]

        if path.startswith('static/') or path == 'todo.html':
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'': TodoNamespace}, self.request)
        else:
            return not_found(start_response)
	def socketio(self,remaining):	
		try:			
			print request
			socketio_manage(request.environ, {'/relay': PersistentConnection}, self)
		except:
			self.app.logger.error("Exception while handling socketio connection",exc_info=True)
		return Response()
Example #46
0
    def __call__(self, environ, start_response):
        path = environ["PATH_INFO"].strip("/")

        if not path:
            start_response("200 OK", [("Content-Type", "text/html")])
            return [TestHtml]

        if path.startswith("static/") or path.startswith("tests/"):
            try:
                data = open(path).read()
            except Exception:
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response("200 OK", [("Content-Type", content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {"/test": TestNamespace})
        else:
            return not_found(start_response)
Example #47
0
def socketio_service(request):
    socketio_manage(request.environ, {
        '': GecosNamespace,
        '/tail': TailNamespace
    },
                    request=request)
    return Response('no-data')
Example #48
0
def application(env, start_response):
	""" Our web serving app """
	path = env['PATH_INFO'].strip('/') or 'index.html'

	# static stuff
	if path.startswith('static/') or path == "index.html":
		try:
			data = open(path).read()
		except Exception:
			return http404(start_response)

		if path.endswith(".js"):
			content_type = "text/javascript"
		elif path.endswith(".css"):
			content_type = "text/css"
		elif path.endswith(".png"):
			content_type = "image/png"
		elif path.endswith(".swf"):
			content_type = "application/x-shockwave-flash"
		else:
			content_type = "text/html"

		start_response('200 OK', [('Content-Type', content_type)])
		return [data]

	# socketIO request
	if path.startswith('socket.io/'):
		socketio_manage(env, {'': LogStreamNS})
	else:
		return http404(start_response)
def handle_socketio_request(remaining):
    try:
        socketio_manage(request.environ, {'': BaseNamespace}, request)
    except Exception:
        current_app.logger.exception('Exception while handling socketio connection')
        raise
    return current_app.response_class()
Example #50
0
def socketio(request):
    try:
        socketio_manage(request.environ, SOCKETIO_NS, request)
    except:
        logging.getLogger("socketio").error(
            "Exception while handling socketio connection", exc_info=True)
    return HttpResponse("")
def run_socketio(path):
    print 'running socket.io on path %s' % path
    socketio_manage(
        request.environ, 
        {#'': ChatNamespace,
         '/chat': ChatNamespace,
         '/test': TestNamespace})
Example #52
0
 def __call__(self, environ, start_response):
     """
     WSGI application handler.
     """
     path = environ["PATH_INFO"]
     if path.startswith("/socket.io/"):
         socketio_manage(environ, {"": IRCNamespace})
         return
     if path.startswith("/webhook/"):
         dispatch = self.respond_webhook
     elif self.django:
         dispatch = self.respond_django
     else:
         dispatch = self.respond_static
     response = dispatch(environ)
     if isinstance(response, int):
         response = (response, [], None)
     elif isinstance(response, basestring):
         response = (200, [], response)
     status, headers, content = response
     status_text = HTTP_STATUS_TEXT.get(status, "")
     headers.append(("Server", settings.GNOTTY_VERSION_STRING))
     start_response("%s %s" % (status, status_text), headers)
     if content is None:
         if status == 200:
             content = ""
         else:
             content = "<h1>%s</h1>" % status_text.title()
     return [content]
Example #53
0
def push_stream(rest):
    try:
        socketio_manage(request.environ, {'/shouts': ShoutNamespace}, request)
    except:
        app.logger.error("Exception lors de la connexion socketio",
                         exc_info=True)
    return Response()
Example #54
0
    def __call__(self, environ, start_response):
        path = environ['PATH_INFO'].strip('/')

        # print environ
        if not path:
            path = 'index.html'

        if path.startswith('static/') or path.endswith(
                'html') or path.endswith('js'):
            try:
                data = open(path).read()
            except Exception:
                print 'Open path exception'
                return not_found(start_response)

            if path.endswith(".js"):
                content_type = "text/javascript"
            elif path.endswith(".css"):
                content_type = "text/css"
            elif path.endswith(".swf"):
                content_type = "application/x-shockwave-flash"
            else:
                content_type = "text/html"

            start_response('200 OK', [('Content-Type', content_type)])
            return [data]

        if path.startswith("socket.io"):
            socketio_manage(environ, {'': OrbitSocket}, self.request)
        else:
            return not_found(start_response)
Example #55
0
def socket_io(request):
    socketio.socketio_manage(request.environ, {
        '/netstat': NetstatWebSocketNamespace,
        '/acp': ACPWebsocketNamespace,
        '/ids': IDSWebsocketNamespace,
    }, request=request)

    return HttpResponse()