From 7b2b3659bb2a19eea0b01a8f64b5ecb4c823a24a Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 30 Oct 2025 19:50:03 +1100 Subject: [PATCH] fix: Remove strict slashes from index routes --- blueprints/api.py | 2 +- blueprints/blog.py | 2 +- blueprints/sol.py | 8 +++++++- blueprints/spotify.py | 2 +- blueprints/template.py | 2 +- blueprints/wellknown.py | 5 +++-- server.py | 8 -------- templates/index.ascii | 2 +- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/blueprints/api.py b/blueprints/api.py index d61f855..267f617 100644 --- a/blueprints/api.py +++ b/blueprints/api.py @@ -30,7 +30,7 @@ if 'time-zone' not in NC_CONFIG: NC_CONFIG['time-zone'] = 10 -@app.route("/") +@app.route("/", strict_slashes=False) @app.route("/help") def help(): """Provide API documentation and help.""" diff --git a/blueprints/blog.py b/blueprints/blog.py index 948edd6..73105ea 100644 --- a/blueprints/blog.py +++ b/blueprints/blog.py @@ -108,7 +108,7 @@ def render_home(handshake_scripts: str | None = None): ) -@app.route("/") +@app.route("/", strict_slashes=False) def index(): if not isCLI(request): return render_home(handshake_scripts=getHandshakeScript(request.host)) diff --git a/blueprints/sol.py b/blueprints/sol.py index 7ad7b94..e7073c7 100644 --- a/blueprints/sol.py +++ b/blueprints/sol.py @@ -122,4 +122,10 @@ def sol_donate_post(amount): return jsonify({"message": "Error: Amount too small"}), 400, SOLANA_HEADERS transaction = create_transaction(sender, amount) - return jsonify({"message": "Success", "transaction": transaction}), 200, SOLANA_HEADERS \ No newline at end of file + return jsonify({"message": "Success", "transaction": transaction}), 200, SOLANA_HEADERS + +@app.route("/actions.json") +def sol_actions(): + return jsonify( + {"rules": [{"pathPattern": "/donate**", "apiPath": "/api/v1/donate**"}]} + ) diff --git a/blueprints/spotify.py b/blueprints/spotify.py index 7cddc48..d4c402a 100644 --- a/blueprints/spotify.py +++ b/blueprints/spotify.py @@ -89,7 +89,7 @@ def callback(): print("Refresh Token:", REFRESH_TOKEN) return redirect(url_for("spotify.currently_playing")) -@app.route("/") +@app.route("/", strict_slashes=False) @app.route("/playing") def currently_playing(): """Public endpoint showing your current track.""" diff --git a/blueprints/template.py b/blueprints/template.py index ea3e3e7..10243a8 100644 --- a/blueprints/template.py +++ b/blueprints/template.py @@ -4,6 +4,6 @@ from tools import json_response app = Blueprint('template', __name__) -@app.route("/") +@app.route("/", strict_slashes=False) def index(): return json_response(request, "Success", 200) \ No newline at end of file diff --git a/blueprints/wellknown.py b/blueprints/wellknown.py index 6334d14..05edc96 100644 --- a/blueprints/wellknown.py +++ b/blueprints/wellknown.py @@ -1,4 +1,5 @@ -from flask import Blueprint, render_template, make_response, request, jsonify, send_from_directory, redirect +from flask import Blueprint, make_response, request, jsonify, send_from_directory, redirect +from tools import error_response import os app = Blueprint('well-known', __name__, url_prefix='/.well-known') @@ -25,7 +26,7 @@ def wallets(path): if os.path.isfile(".well-known/wallets/" + path.upper()): return redirect("/.well-known/wallets/" + path.upper(), code=302) - return render_template("404.html"), 404 + return error_response(request) @app.route("/nostr.json") diff --git a/server.py b/server.py index 4c46ac8..ab2dada 100644 --- a/server.py +++ b/server.py @@ -179,7 +179,6 @@ def serviceWorker(): # region Misc routes - @app.route("/meet") @app.route("/meeting") @app.route("/appointment") @@ -203,13 +202,6 @@ def api_legacy(function): return redirect(f"/api/v1/{function}", code=301) return error_response(request, message="404 Not Found", code=404) - -@app.route("/actions.json") -def sol_actions(): - return jsonify( - {"rules": [{"pathPattern": "/donate**", "apiPath": "/api/v1/donate**"}]} - ) - # endregion # region Main routes diff --git a/templates/index.ascii b/templates/index.ascii index ea46740..902e608 100644 --- a/templates/index.ascii +++ b/templates/index.ascii @@ -9,7 +9,7 @@ Contact [/contact] Projects [/projects] Tools [/tools] Donate [/donate] -API [/api/v1/] +API [/api/v1] ───────────────────────────────────────────────  ABOUT ME