-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add base url path param #2925
Closed
Closed
Add base url path param #2925
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0f4ff9c
save progress working app
Grommash9 1aac453
remove master base url param, remove hack from BaseSocket ruff lint
Grommash9 80fff4d
move base url in the end of path and fix print logs on running and er…
Grommash9 1299852
create_worker_runner base_url default empty string added
Grommash9 75ca5c2
log message formatting update
Grommash9 3175750
add default base url value to WorkerRunner
Grommash9 007cd2e
add web UI empty param
Grommash9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,7 @@ def __init__( | |
environment: Environment, | ||
host: str, | ||
port: int, | ||
base_url: str, | ||
web_login: bool = False, | ||
tls_cert: str | None = None, | ||
tls_key: str | None = None, | ||
|
@@ -117,6 +118,7 @@ def __init__( | |
self.environment = environment | ||
self.host = host | ||
self.port = port | ||
self.base_url = base_url | ||
self.tls_cert = tls_cert | ||
self.tls_key = tls_key | ||
self.userclass_picker_is_active = userclass_picker_is_active | ||
|
@@ -134,7 +136,6 @@ def __init__( | |
self.app.static_url_path = "/assets/" | ||
# ensures static js files work on Windows | ||
mimetypes.add_type("application/javascript", ".js") | ||
|
||
if self.web_login: | ||
self._login_manager = LoginManager() | ||
self._login_manager.init_app(self.app) | ||
|
@@ -155,7 +156,7 @@ def handle_exception(error): | |
) | ||
return make_response(error_message, error_code) | ||
|
||
@app.route("/assets/<path:path>") | ||
@app.route(f"{self.base_url}/assets/<path:path>") | ||
def send_assets(path): | ||
directory = ( | ||
os.path.join(self.app.template_folder, "assets") | ||
|
@@ -165,7 +166,7 @@ def send_assets(path): | |
|
||
return send_from_directory(directory, path) | ||
|
||
@app.route("/") | ||
@app.route(f"{self.base_url}/") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
@self.auth_required_if_enabled | ||
def index() -> str | Response: | ||
if not environment.runner: | ||
|
@@ -174,7 +175,7 @@ def index() -> str | Response: | |
|
||
return render_template("index.html", template_args=self.template_args) | ||
|
||
@app.route("/swarm", methods=["POST"]) | ||
@app.route(f"{self.base_url}/swarm", methods=["POST"]) | ||
@self.auth_required_if_enabled | ||
def swarm() -> Response: | ||
assert request.method == "POST" | ||
|
@@ -288,7 +289,7 @@ def swarm() -> Response: | |
else: | ||
return jsonify({"success": False, "message": "No runner", "host": environment.host}) | ||
|
||
@app.route("/stop") | ||
@app.route(f"{self.base_url}/stop") | ||
@self.auth_required_if_enabled | ||
def stop() -> Response: | ||
if self._swarm_greenlet is not None: | ||
|
@@ -298,7 +299,7 @@ def stop() -> Response: | |
environment.runner.stop() | ||
return jsonify({"success": True, "message": "Test stopped"}) | ||
|
||
@app.route("/stats/reset") | ||
@app.route(f"{self.base_url}/stats/reset") | ||
@self.auth_required_if_enabled | ||
def reset_stats() -> str: | ||
environment.events.reset_stats.fire() | ||
|
@@ -307,7 +308,7 @@ def reset_stats() -> str: | |
environment.runner.exceptions = {} | ||
return "ok" | ||
|
||
@app.route("/stats/report") | ||
@app.route(f"{self.base_url}/stats/report") | ||
@self.auth_required_if_enabled | ||
def stats_report() -> Response: | ||
theme = request.args.get("theme", "") | ||
|
@@ -345,15 +346,15 @@ def _download_csv_response(csv_data: str, filename_prefix: str) -> Response: | |
) | ||
return response | ||
|
||
@app.route("/stats/requests/csv") | ||
@app.route(f"{self.base_url}/stats/requests/csv") | ||
@self.auth_required_if_enabled | ||
def request_stats_csv() -> Response: | ||
data = StringIO() | ||
writer = csv.writer(data) | ||
self.stats_csv_writer.requests_csv(writer) | ||
return _download_csv_response(data.getvalue(), "requests") | ||
|
||
@app.route("/stats/requests_full_history/csv") | ||
@app.route(f"{self.base_url}/stats/requests_full_history/csv") | ||
@self.auth_required_if_enabled | ||
def request_stats_full_history_csv() -> Response: | ||
options = self.environment.parsed_options | ||
|
@@ -371,15 +372,15 @@ def request_stats_full_history_csv() -> Response: | |
|
||
return make_response("Error: Server was not started with option to generate full history.", 404) | ||
|
||
@app.route("/stats/failures/csv") | ||
@app.route(f"{self.base_url}/stats/failures/csv") | ||
@self.auth_required_if_enabled | ||
def failures_stats_csv() -> Response: | ||
data = StringIO() | ||
writer = csv.writer(data) | ||
self.stats_csv_writer.failures_csv(writer) | ||
return _download_csv_response(data.getvalue(), "failures") | ||
|
||
@app.route("/stats/requests") | ||
@app.route(f"{self.base_url}/stats/requests") | ||
@self.auth_required_if_enabled | ||
@memoize(timeout=DEFAULT_CACHE_TIME, dynamic_timeout=True) | ||
def request_stats() -> Response: | ||
|
@@ -449,7 +450,7 @@ def request_stats() -> Response: | |
|
||
return jsonify(report) | ||
|
||
@app.route("/exceptions") | ||
@app.route(f"{self.base_url}/exceptions") | ||
@self.auth_required_if_enabled | ||
def exceptions() -> Response: | ||
return jsonify( | ||
|
@@ -466,15 +467,15 @@ def exceptions() -> Response: | |
} | ||
) | ||
|
||
@app.route("/exceptions/csv") | ||
@app.route(f"{self.base_url}/exceptions/csv") | ||
@self.auth_required_if_enabled | ||
def exceptions_csv() -> Response: | ||
data = StringIO() | ||
writer = csv.writer(data) | ||
self.stats_csv_writer.exceptions_csv(writer) | ||
return _download_csv_response(data.getvalue(), "exceptions") | ||
|
||
@app.route("/tasks") | ||
@app.route(f"{self.base_url}/tasks") | ||
@self.auth_required_if_enabled | ||
def tasks() -> dict[str, dict[str, dict[str, float]]]: | ||
runner = self.environment.runner | ||
|
@@ -494,12 +495,12 @@ def tasks() -> dict[str, dict[str, dict[str, float]]]: | |
} | ||
return task_data | ||
|
||
@app.route("/logs") | ||
@app.route(f"{self.base_url}/logs") | ||
@self.auth_required_if_enabled | ||
def logs(): | ||
return jsonify({"master": get_logs(), "workers": self.environment.worker_logs}) | ||
|
||
@app.route("/login") | ||
@app.route(f"{self.base_url}/login") | ||
def login(): | ||
if not self.web_login: | ||
return redirect(url_for("index")) | ||
|
@@ -509,7 +510,7 @@ def login(): | |
auth_args=self.auth_args, | ||
) | ||
|
||
@app.route("/user", methods=["POST"]) | ||
@app.route(f"{self.base_url}/user", methods=["POST"]) | ||
def update_user(): | ||
assert request.method == "POST" | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
url
doesn't actually make sense in this case, URL refers to the entire composition (e.g. protocol://domain:port/path?query=params), in this casebase_path
would be more accurate