def start(host: str = "", port: int = 9090, ssl: bool = False, ssl_protocol: int = _ssl.PROTOCOL_TLS_SERVER, ssl_check_hostname: bool = False, keyfile: str = "", certfile: str = "", keypass: str = "", ssl_context: _ssl.SSLContext = None, resources: Dict[str, str] = {}) -> None: with __lock: global _server if _server is not None: _server.shutdown() _server = http_server.SimpleDispatcherHttpServer( host=(host, port), ssl=ssl, ssl_protocol=ssl_protocol, ssl_check_hostname=ssl_check_hostname, keyfile=keyfile, certfile=certfile, keypass=keypass, ssl_context=ssl_context, resources=resources) filters = _get_filters() # filter configuration for ft in filters: _server.map_filter(ft["url_pattern"], ft["func"]) request_mappings = _get_request_mappings() # request mapping for ctr in request_mappings: _server.map_request(ctr) ws_handlers = _get_websocket_handlers() for endpoint, clz in ws_handlers.items(): _server.map_websocket_handler(endpoint, clz) err_pages = _get_error_pages() for code, func in err_pages.items(): _server.map_error_page(code, func) # start the server _server.start()
def start(host="", port=9090): with __lock: global __server __server = http_server.SimpleDispatcherHttpServer((host, port)) from simple_http_server import _get_filters __filters = _get_filters() # filter configuration for ft in __filters: __server.map_filter(ft["url_pattern"], ft["func"]) from simple_http_server import _get_request_mappings __request_mappings = _get_request_mappings() # request mapping for ctr in __request_mappings: __server.map_request(ctr["url"], ctr["func"], ctr["method"]) # start the server __server.start()
def start(host: str = "", port: int = 9090, ssl: bool = False, ssl_protocol: int = _ssl.PROTOCOL_TLS_SERVER, ssl_check_hostname: bool = False, keyfile: str = "", certfile: str = "", keypass: str = "", ssl_context: _ssl.SSLContext = None, resources: Dict[str, str] = {}) -> None: with __lock: global __server if __server is not None: __server.shutdown() __server = http_server.SimpleDispatcherHttpServer( host=(host, port), ssl=ssl, ssl_protocol=ssl_protocol, ssl_check_hostname=ssl_check_hostname, keyfile=keyfile, certfile=certfile, keypass=keypass, ssl_context=ssl_context, resources=resources) __filters = _get_filters() # filter configuration for ft in __filters: __server.map_filter(ft["url_pattern"], ft["func"]) __request_mappings = _get_request_mappings() # request mapping for ctr in __request_mappings: __server.map_request(ctr) # start the server __server.start()