diff --git a/examples/web_ui_auth/basic.py b/examples/web_ui_auth/basic.py index 44158c53cd..0c945523ab 100644 --- a/examples/web_ui_auth/basic.py +++ b/examples/web_ui_auth/basic.py @@ -36,14 +36,14 @@ def load_user(username): @events.init.add_listener def locust_init(environment, **_kwargs): if environment.web_ui: - auth_blueprint = Blueprint("auth", "web_ui_auth", url_prefix=environment.parsed_options.base_path) + auth_blueprint = Blueprint("auth", "web_ui_auth", url_prefix=environment.parsed_options.web_base_path) environment.web_ui.login_manager.user_loader(load_user) environment.web_ui.app.config["SECRET_KEY"] = os.getenv("FLASK_SECRET_KEY") environment.web_ui.auth_args = { - "username_password_callback": f"{environment.parsed_options.base_path}/login_submit", + "username_password_callback": f"{environment.parsed_options.web_base_path}/login_submit", "auth_providers": [ { "label": "Github", diff --git a/examples/web_ui_auth/custom_form.py b/examples/web_ui_auth/custom_form.py index 1641beafb8..2b29accdfd 100644 --- a/examples/web_ui_auth/custom_form.py +++ b/examples/web_ui_auth/custom_form.py @@ -41,7 +41,7 @@ def load_user(user_id): @events.init.add_listener def locust_init(environment, **_kwargs): if environment.web_ui: - auth_blueprint = Blueprint("auth", "web_ui_auth", url_prefix=environment.parsed_options.base_path) + auth_blueprint = Blueprint("auth", "web_ui_auth", url_prefix=environment.parsed_options.web_base_path) environment.web_ui.login_manager.user_loader(load_user) @@ -69,7 +69,7 @@ def locust_init(environment, **_kwargs): "is_secret": True, }, ], - "callback_url": f"{environment.parsed_options.base_path}/login_submit", + "callback_url": f"{environment.parsed_options.web_base_path}/login_submit", "submit_button_text": "Submit", }, } diff --git a/locust/argument_parser.py b/locust/argument_parser.py index 5a52a03e80..6dc7d3c3f4 100644 --- a/locust/argument_parser.py +++ b/locust/argument_parser.py @@ -613,11 +613,11 @@ def setup_parser_arguments(parser): ) web_ui_group.add_argument( - "--base-path", + "--web-base-path", type=str, default="", help="Base path for the web interface (e.g., '/locust'). Default is empty (root path).", - env_var="BASE_PATH", + env_var="LOCUST_web_base_path", ) tag_group = parser.add_argument_group( diff --git a/locust/env.py b/locust/env.py index 435a8e54e1..a711fcde1b 100644 --- a/locust/env.py +++ b/locust/env.py @@ -165,7 +165,7 @@ def create_web_ui( self, host="", port=8089, - base_path: str | None = None, + web_base_path: str | None = None, web_login: bool = False, tls_cert: str | None = None, tls_key: str | None = None, @@ -200,7 +200,7 @@ def create_web_ui( delayed_start=delayed_start, userclass_picker_is_active=userclass_picker_is_active, build_path=build_path, - base_path=base_path, + web_base_path=web_base_path, ) return self.web_ui diff --git a/locust/main.py b/locust/main.py index 3efd21e7db..030394c940 100644 --- a/locust/main.py +++ b/locust/main.py @@ -455,7 +455,7 @@ def ensure_user_class_name(config): try: runner = environment.create_worker_runner(options.master_host, options.master_port) logger.debug( - "Connected to locust master: %s:%s%s", options.master_host, options.master_port, options.base_path + "Connected to locust master: %s:%s%s", options.master_host, options.master_port, options.web_base_path ) except OSError as e: logger.error("Failed to connect to the Locust master: %s", e) @@ -498,21 +498,21 @@ def ensure_user_class_name(config): else: web_host = options.web_host if web_host: - logger.info(f"Starting web interface at {protocol}://{web_host}:{options.web_port}{options.base_path}") + logger.info(f"Starting web interface at {protocol}://{web_host}:{options.web_port}{options.web_base_path}") if options.web_host_display_name: logger.info(f"Starting web interface at {options.web_host_display_name}") else: if os.name == "nt": logger.info( - f"Starting web interface at {protocol}://localhost:{options.web_port}{options.base_path} (accepting connections from all network interfaces)" + f"Starting web interface at {protocol}://localhost:{options.web_port}{options.web_base_path} (accepting connections from all network interfaces)" ) else: - logger.info(f"Starting web interface at {protocol}://0.0.0.0:{options.web_port}{options.base_path}") + logger.info(f"Starting web interface at {protocol}://0.0.0.0:{options.web_port}{options.web_base_path}") web_ui = environment.create_web_ui( host=web_host, port=options.web_port, - base_path=options.base_path, + web_base_path=options.web_base_path, web_login=options.web_login, tls_cert=options.tls_cert, tls_key=options.tls_key, diff --git a/locust/runners.py b/locust/runners.py index 7c73b4bb84..8afb4a06a1 100644 --- a/locust/runners.py +++ b/locust/runners.py @@ -1475,11 +1475,11 @@ def connect_to_master(self): if not success: if self.retry < 3: logger.debug( - f"Failed to connect to master {self.master_host}:{self.master_port}{self.environment.parsed_options.base_path}, retry {self.retry}/{CONNECT_RETRY_COUNT}." + f"Failed to connect to master {self.master_host}:{self.master_port}{self.environment.parsed_options.web_base_path}, retry {self.retry}/{CONNECT_RETRY_COUNT}." ) else: logger.warning( - f"Failed to connect to master {self.master_host}:{self.master_port}{self.environment.parsed_options.base_path}, retry {self.retry}/{CONNECT_RETRY_COUNT}." + f"Failed to connect to master {self.master_host}:{self.master_port}{self.environment.parsed_options.web_base_path}, retry {self.retry}/{CONNECT_RETRY_COUNT}." ) if self.retry > CONNECT_RETRY_COUNT: raise ConnectionError() diff --git a/locust/web.py b/locust/web.py index 88bc18892c..06bb72e7a2 100644 --- a/locust/web.py +++ b/locust/web.py @@ -121,7 +121,7 @@ def __init__( environment: Environment, host: str, port: int, - base_path: str | None = None, + web_base_path: str | None = None, web_login: bool = False, tls_cert: str | None = None, tls_key: str | None = None, @@ -164,7 +164,7 @@ def __init__( self.app.template_folder = build_path or DEFAULT_BUILD_PATH self.app.static_url_path = "/assets/" - app_blueprint = Blueprint("locust", __name__, url_prefix=base_path) + app_blueprint = Blueprint("locust", __name__, url_prefix=web_base_path) # ensures static js files work on Windows mimetypes.add_type("application/javascript", ".js") if self.web_login: