diff --git a/pype/modules/rest_api/rest_api.py b/pype/modules/rest_api/rest_api.py index a30402b5fe..b37f5e13eb 100644 --- a/pype/modules/rest_api/rest_api.py +++ b/pype/modules/rest_api/rest_api.py @@ -107,7 +107,6 @@ class RestApiModule(PypeModule, ITrayService): self.rest_api_url = None self.rest_api_thread = None - self.resources_url = None def register_callback( self, path, callback, url_prefix="", methods=[], strict_match=False @@ -189,11 +188,9 @@ class RestApiModule(PypeModule, ITrayService): self.rest_api_url = "http://localhost:{}".format(port) self.rest_api_thread = RestApiThread(self, port) self.register_statics("/res", resources.RESOURCES_DIR) - self.resources_url = "{}/res".format(self.rest_api_url) # Set rest api environments os.environ["PYPE_REST_API_URL"] = self.rest_api_url - os.environ["PYPE_STATICS_SERVER"] = self.resources_url def tray_start(self): RestApiFactory.prepare_registered() diff --git a/pype/modules/webserver/webserver_module.py b/pype/modules/webserver/webserver_module.py index 86afffd958..0cdf478d8c 100644 --- a/pype/modules/webserver/webserver_module.py +++ b/pype/modules/webserver/webserver_module.py @@ -1,3 +1,5 @@ +import os +from pype import resources from .. import PypeModule, ITrayService @@ -17,6 +19,7 @@ class WebServerModule(PypeModule, ITrayService): def tray_init(self): self.create_server_manager() + self._add_resources_statics() def tray_start(self): self.start_server() @@ -24,6 +27,14 @@ class WebServerModule(PypeModule, ITrayService): def tray_exit(self): self.stop_server() + def _add_resources_statics(self): + static_prefix = "/res" + self.server_manager.add_static(static_prefix, resources.RESOURCES_DIR) + + os.environ["PYPE_STATICS_SERVER"] = "http://localhost:{}{}".format( + self.port, static_prefix + ) + def start_server(self): if self.server_manager: self.server_manager.start_server()