예제 #1
0
            self.server.prev_drawing()
        elif event[0] == 'KD':
            if event[1] == '85':  # 'U'
                self.server.undo()
            elif event[1] == '82':  # 'R'
                self.server.set_drawing(self.server.timestamp)
        else:
            W('unknown event: %r\n' % (event, ))
        return False


if __name__ == '__main__':
    import coro.http
    import coro.backdoor
    import os
    cwd = os.getcwd()
    sketch_server = server()
    ih = coro.http.handlers.favicon_handler()
    sh = coro.http.handlers.coro_status_handler()
    wh = handler('/sketch', sketch_server.new_session)
    fh = coro.http.handlers.file_handler(cwd)
    handlers = [wh, ih, sh, fh]
    # server = coro.http.server (('0.0.0.0', 9001))
    server = coro.http.server()
    for h in handlers:
        server.push_handler(h)
    # coro.spawn (server.start)
    coro.spawn(server.start, ('0.0.0.0', 9001))
    coro.spawn(coro.backdoor.serve, unix_path='/tmp/ws.bd')
    coro.event_loop(30.0)
예제 #2
0
class echo_server(websocket):
    def __init__(self, *args, **kwargs):
        self.pending = []
        websocket.__init__(self, *args, **kwargs)

    def handle_packet(self, p):
        # W ('packet=%r\n' % (p,))
        self.pending.append(p.unpack())
        if p.fin:
            data, self.pending = self.pending, []
            self.send_text(''.join(data))
        return False


if __name__ == '__main__':
    import coro.http
    import coro.backdoor
    fh = coro.http.handlers.favicon_handler()
    sh = coro.http.handlers.coro_status_handler()
    wh = handler('/echo', echo_server)
    handlers = [fh, sh, wh]
    # server = coro.http.server (('0.0.0.0', 9001))
    server = coro.http.server()
    for h in handlers:
        server.push_handler(h)
    # coro.spawn (server.start)
    coro.spawn(server.start, ('0.0.0.0', 9001))
    coro.spawn(coro.backdoor.serve, unix_path='/tmp/ws.bd')
    coro.event_loop(30.0)
예제 #3
0
파일: field.py 프로젝트: pandyxu/shrapnel
        x0, y0 = self.mouse_down
        if x0:
            if abs(x1-x0) > 10 or abs(y1-y0) > 10:
                # moved enough to redraw
                self.mouse_down = x1, y1
                self.move_window (x0-x1, y0-y1)

if __name__ == '__main__':
    import coro.http
    import coro.backdoor
    import os
    cwd = os.getcwd()
    f = field()
    ih = coro.http.handlers.favicon_handler()
    sh = coro.http.handlers.coro_status_handler()
    th = handler ('/field', f.new_conn)
    fh = coro.http.handlers.file_handler (cwd)
    # so you can browse the source
    import mimetypes
    mimetypes.init()
    mimetypes.add_type ('text/plain', '.py')
    handlers = [th, ih, sh, fh]
    #server = coro.http.server (('0.0.0.0', 9001))
    server = coro.http.server()
    for h in handlers:
        server.push_handler (h)
    #coro.spawn (server.start)
    coro.spawn (server.start, ('0.0.0.0', 9001))
    coro.spawn (coro.backdoor.serve, unix_path='/tmp/ws.bd')
    coro.event_loop (30.0)
예제 #4
0
파일: term.py 프로젝트: amitdev/shrapnel
            self.sock.send_text ('D' + escape ('goodbye!\n'))
            self.sock.conn.close()
        else:
            return line

    def send (self, data):
        # Note: sock is really a terminal object
        self.sock.send_text ('D' + escape (data))

if __name__ == '__main__':
    import coro.http
    import coro.backdoor
    import os
    ih = coro.http.handlers.favicon_handler()
    sh = coro.http.handlers.coro_status_handler()
    th = handler ('/term', terminal)
    th.auth_dict = {'foo': 'bar'}
    # serve files out of this directory
    fh = coro.http.handlers.file_handler (os.getcwd())
    handlers = [th, ih, sh, fh]
    # server = coro.http.server()
    # server = coro.http.tlslite_server (
    # should point to the test cert in coro/http/cert/
    #    '../../../cert/server.crt',
    #    '../../../cert/server.key',
    #    )
    import coro.ssl
    from coro.ssl import openssl
    ctx = coro.ssl.new_ctx (
        cert=openssl.x509 (open('../../../cert/server.crt').read()),
        key=openssl.pkey (open('../../../cert/server.key').read(), private=True),
예제 #5
0
        if x0:
            if abs(x1 - x0) > 10 or abs(y1 - y0) > 10:
                # moved enough to redraw
                self.mouse_down = x1, y1
                self.move_window(x0 - x1, y0 - y1)


if __name__ == '__main__':
    import coro.http
    import coro.backdoor
    import os
    cwd = os.getcwd()
    f = field()
    ih = coro.http.handlers.favicon_handler()
    sh = coro.http.handlers.coro_status_handler()
    th = handler('/field', f.new_conn)
    fh = coro.http.handlers.file_handler(cwd)
    # so you can browse the source
    import mimetypes
    mimetypes.init()
    mimetypes.add_type('text/plain', '.py')
    handlers = [th, ih, sh, fh]
    # server = coro.http.server (('0.0.0.0', 9001))
    server = coro.http.server()
    for h in handlers:
        server.push_handler(h)
    # coro.spawn (server.start)
    coro.spawn(server.start, ('0.0.0.0', 9001))
    coro.spawn(coro.backdoor.serve, unix_path='/tmp/ws.bd')
    coro.event_loop(30.0)
예제 #6
0
class echo_server (websocket):

    def __init__ (self, *args, **kwargs):
        self.pending = []
        websocket.__init__ (self, *args, **kwargs)

    def handle_packet (self, p):
        # W ('packet=%r\n' % (p,))
        self.pending.append (p.unpack())
        if p.fin:
            data, self.pending = self.pending, []
            self.send_text (''.join (data))
        return False

if __name__ == '__main__':
    import coro.http
    import coro.backdoor
    fh = coro.http.handlers.favicon_handler()
    sh = coro.http.handlers.coro_status_handler()
    wh = handler ('/echo', echo_server)
    handlers = [fh, sh, wh]
    # server = coro.http.server (('0.0.0.0', 9001))
    server = coro.http.server ()
    for h in handlers:
        server.push_handler (h)
    # coro.spawn (server.start)
    coro.spawn (server.start, ('0.0.0.0', 9001))
    coro.spawn (coro.backdoor.serve, unix_path='/tmp/ws.bd')
    coro.event_loop (30.0)
예제 #7
0
                'type': 'message',
                'data': {
                    'time': int(coro.now_usec / 1000000),
                    'text': message,
                    'author': name,
                    'color': color
                }
            }))


if __name__ == '__main__':
    import coro.http
    import coro.backdoor
    import os
    cwd = os.getcwd()

    chat_server = server()

    ih = coro.http.handlers.favicon_handler()
    sh = coro.http.handlers.coro_status_handler()
    fh = coro.http.handlers.file_handler(cwd)
    wh = handler('/chat', chat_server.new_session)
    handlers = [ih, sh, fh, wh]
    # http_server = coro.http.server (('0.0.0.0', 9001))
    http_server = coro.http.server()
    for h in handlers:
        http_server.push_handler(h)
    coro.spawn(http_server.start, ('0.0.0.0', 9001))
    coro.spawn(coro.backdoor.serve, unix_path='/tmp/ws_chat.bd')
    coro.event_loop(30.0)
예제 #8
0
                'type':'message',
                'data': {
                    'time' : int (coro.now_usec / 1000000),
                    'text' : message,
                    'author' : name,
                    'color' : color
                    }
                })
            )

if __name__ == '__main__':
    import coro.http
    import coro.backdoor
    import os
    cwd = os.getcwd()

    chat_server = server()

    ih = coro.http.handlers.favicon_handler()
    sh = coro.http.handlers.coro_status_handler()
    fh = coro.http.handlers.file_handler (cwd)
    wh = handler ('/chat', chat_server.new_session)
    handlers = [ih, sh, fh, wh]
    #http_server = coro.http.server (('0.0.0.0', 9001))
    http_server = coro.http.server ()
    for h in handlers:
        http_server.push_handler (h)
    coro.spawn (http_server.start, ('0.0.0.0', 9001))
    coro.spawn (coro.backdoor.serve, unix_path='/tmp/ws_chat.bd')
    coro.event_loop (30.0)
예제 #9
0
            self.sock.conn.close()
        else:
            return line

    def send(self, data):
        # Note: sock is really a terminal object
        self.sock.send_text('D' + escape(data))


if __name__ == '__main__':
    import coro.http
    import coro.backdoor
    import os
    ih = coro.http.handlers.favicon_handler()
    sh = coro.http.handlers.coro_status_handler()
    th = handler('/term', terminal)
    th.auth_dict = {'foo': 'bar'}
    # serve files out of this directory
    fh = coro.http.handlers.file_handler(os.getcwd())
    handlers = [th, ih, sh, fh]
    # server = coro.http.server()
    # server = coro.http.tlslite_server (
    # should point to the test cert in coro/http/cert/
    #    '../../../cert/server.crt',
    #    '../../../cert/server.key',
    #    )
    import coro.ssl
    from coro.ssl import openssl
    ctx = coro.ssl.new_ctx(
        cert=openssl.x509(open('../../../cert/server.crt').read()),
        key=openssl.pkey(open('../../../cert/server.key').read(),
예제 #10
0
파일: simple.py 프로젝트: amitdev/shrapnel
        elif event[0] == 'PD':
            self.server.prev_drawing()
        elif event[0] == 'KD':
            if event[1] == '85':  # 'U'
                self.server.undo()
            elif event[1] == '82':  # 'R'
                self.server.set_drawing (self.server.timestamp)
        else:
            W ('unknown event: %r\n' % (event,))
        return False

if __name__ == '__main__':
    import coro.http
    import coro.backdoor
    import os
    cwd = os.getcwd()
    sketch_server = server()
    ih = coro.http.handlers.favicon_handler()
    sh = coro.http.handlers.coro_status_handler()
    wh = handler ('/sketch', sketch_server.new_session)
    fh = coro.http.handlers.file_handler (cwd)
    handlers = [wh, ih, sh, fh]
    # server = coro.http.server (('0.0.0.0', 9001))
    server = coro.http.server()
    for h in handlers:
        server.push_handler (h)
    # coro.spawn (server.start)
    coro.spawn (server.start, ('0.0.0.0', 9001))
    coro.spawn (coro.backdoor.serve, unix_path='/tmp/ws.bd')
    coro.event_loop (30.0)