MCPcopy Index your code
hub / github.com/rawpython/remi / Server

Class Server

remi/server.py:816–918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

814
815
816class Server(object):
817 # noinspection PyShadowingNames
818 def __init__(self, gui_class, title='', start=True, address='127.0.0.1', port=0, username=None, password=None,
819 multiple_instance=False, enable_file_cache=True, update_interval=0.1, start_browser=True,
820 websocket_timeout_timer_ms=1000, pending_messages_queue_length=1000,
821 certfile=None, keyfile=None, ssl_version=None, userdata=()):
822
823 self._gui = gui_class
824 self._title = title or gui_class.__name__
825 self._sserver = None
826 self._sth = None
827 self._base_address = ''
828 self._address = address
829 self._sport = port
830 self._multiple_instance = multiple_instance
831 self._enable_file_cache = enable_file_cache
832 self._update_interval = update_interval
833 self._start_browser = start_browser
834 self._websocket_timeout_timer_ms = websocket_timeout_timer_ms
835 self._pending_messages_queue_length = pending_messages_queue_length
836 self._certfile = certfile
837 self._keyfile = keyfile
838 self._ssl_version = ssl_version
839 self._userdata = userdata
840 if username and password:
841 self._auth = base64.b64encode(encode_text("%s:%s" % (username, password)))
842 else:
843 self._auth = None
844
845 if not isinstance(userdata, tuple):
846 raise ValueError('userdata must be a tuple')
847
848 self._log = logging.getLogger('remi.server')
849 self._alive = True
850 if start:
851 self._myid = threading.Thread.ident
852 self.start()
853 self.serve_forever()
854
855 @property
856 def title(self):
857 return self._title
858
859 @property
860 def address(self):
861 return self._base_address
862
863 def start(self):
864 # Create a web server and define the handler to manage the incoming
865 # request
866 self._sserver = ThreadedHTTPServer((self._address, self._sport), self._gui, self._auth,
867 self._multiple_instance, self._enable_file_cache,
868 self._update_interval, self._websocket_timeout_timer_ms,
869 self._pending_messages_queue_length, self._title,
870 self, self._certfile, self._keyfile, self._ssl_version, *self._userdata)
871 shost, sport = self._sserver.socket.getsockname()[:2]
872 self._log.info('Started httpserver http://%s:%s/'%(shost,sport))
873 # when listening on multiple net interfaces the browsers connects to localhost

Callers 1

startFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected