Esempio n. 1
0
 def __init__(self, port, is_https):
     WSGIApplication.__init__(self, self._gen_handlers(), "",
                              **self.settings)
     self.jinja_env = self._gen_jinja_env()
     super(HttpRpcServer, self).__init__(
         PT_HTTPS if is_https else PT_HTTP, port,
         WSGIServer(('', port), self, **self.ssl_args if is_https else {}))
Esempio n. 2
0
	def __init__(self, rest_handlers, resource=None, handlers=None, default_host="", **settings):
		restservices = []
		self.resource = resource
		for r in rest_handlers:
			svs = self._generateRestServices(r)
			restservices += svs
		if handlers != None:
			restservices += handlers
		WSGIApplication.__init__(self, restservices, default_host, **settings)
Esempio n. 3
0
 def __init__(self,
              ssl_args,
              port,
              handlers=None,
              default_host="",
              jinja_env=None,
              **settings):
     handlers += [url("/ping", HttpPingHandle, {}, "ping handler")]
     handlers += [
         url("/set_logger_level", SetLoggerLevelHandle, {},
             "Set Logger Level handler")
     ]
     WSGIApplication.__init__(self, handlers, default_host, **settings)
     self.server = WSGIServer(('', port), self, **ssl_args)
     self.port = port
     self.protocol = PT_HTTPS if ssl_args else PT_HTTP
     self.jinja_env = jinja_env
Esempio n. 4
0
    def __init__(self, port, host_name):
        self.port = port
        self.host_name = host_name

        #self.db = PangeaDb()
        self.db = PangeaDb()
        self.table_service = TableService(self.db)

        object_id_regex = "[0-9a-fA-F]{24}"

        if "OPENSHIFT_REPO_DIR" in os.environ:
            static_path = os.path.join(os.environ['OPENSHIFT_REPO_DIR'], "static")
            template_path = os.path.join(os.environ['OPENSHIFT_REPO_DIR'], "templates")
        else:
            static_path = os.path.join(os.path.dirname(__file__), "static")
            template_path = os.path.join(os.path.dirname(__file__), "templates")

        handlers = [
            (r"/", IndexHandler),
            (r"/css/(.*)", StaticFileHandler, {"path": "./static/css"}),
            (r"/js/(.*)", StaticFileHandler, {"path": "./static/js"}),
            (r"/api/lobbies/({0})".format(object_id_regex), LobbyHandler),
            (r"/api/lobbies$", LobbyHandler),
            (r"/api/tables/({0})".format(object_id_regex), TableHandler),
            (r"/api/tables/status/({0})".format(object_id_regex), TableStatusHandler),
            (r"/api/tables$", TableHandler),
            (r"/api/players/({0})".format(object_id_regex), PlayerHandler),
            (r"/api/players$", PlayerHandler),
            (r"/api/seats$", SeatsHandler),
            (r"/api/bets$", BetHandler),
            (r"/api/chats$", ChatHandler)
        ]

        settings = dict(
            template_path=template_path,
            static_path=static_path,
            #debug=True
        )
        WSGIApplication.__init__(self, handlers, **settings)

        #callback = PeriodicCallback(self.kick_timed_out_players, 30000)
        callback = PeriodicCallback(self.kick_timed_out_players, 5000)
        callback.start()
Esempio n. 5
0
 def __init__(self, port, is_https):
     WSGIApplication.__init__(self, self._gen_handlers(), "", **self.settings)
     self.jinja_env = self._gen_jinja_env()
     super(HttpRpcServer, self).__init__(PT_HTTPS if is_https else PT_HTTP,
                                         port,
                                         WSGIServer(('', port), self, **self.ssl_args if is_https else {}))