Skip to content

Instantly share code, notes, and snippets.

@jorgehatccrma
Last active August 29, 2015 14:00
Show Gist options
  • Save jorgehatccrma/11301870 to your computer and use it in GitHub Desktop.
Save jorgehatccrma/11301870 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# encoding: utf-8
from gevent import monkey; monkey.patch_all()
from socketio.namespace import BaseNamespace
from socketio import socketio_manage
from bottle import route, request, static_file, run
import logging
logging.basicConfig()
######################################################
# serve static content
######################################################
@route('/static/<path:path>')
def server_static(path):
return static_file(path, root='static')
######################################################
# gevent-socketio stuff
######################################################
class TestCommNamespace(BaseNamespace):
def initialize(self):
self.emit('test', 'booya!!!')
def on_check(self):
print "got checked"
# hook gevent-socketio to bottle
@route('/socket.io/<path:path>')
def socketio_service(path):
socketio_manage(request.environ,
{'/check': TestCommNamespace},
request)
######################################################
# entry point
######################################################
def main():
debug_mode = True;
reload_mode = True;
run(server='geventSocketIO',
host='0.0.0.0',
port=8000,
debug=debug_mode,
reloader=reload_mode)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment