2 Commits

Author SHA1 Message Date
7b2b3659bb fix: Remove strict slashes from index routes
All checks were successful
Build Docker / BuildImage (push) Successful in 48s
2025-10-30 19:50:03 +11:00
872373dffd feat: Remove strict slashes for now pages 2025-10-30 19:44:01 +11:00
9 changed files with 24 additions and 24 deletions

View File

@@ -30,7 +30,7 @@ if 'time-zone' not in NC_CONFIG:
NC_CONFIG['time-zone'] = 10 NC_CONFIG['time-zone'] = 10
@app.route("/") @app.route("/", strict_slashes=False)
@app.route("/help") @app.route("/help")
def help(): def help():
"""Provide API documentation and help.""" """Provide API documentation and help."""

View File

@@ -108,7 +108,7 @@ def render_home(handshake_scripts: str | None = None):
) )
@app.route("/") @app.route("/", strict_slashes=False)
def index(): def index():
if not isCLI(request): if not isCLI(request):
return render_home(handshake_scripts=getHandshakeScript(request.host)) return render_home(handshake_scripts=getHandshakeScript(request.host))

View File

@@ -77,15 +77,17 @@ def render_curl(date=None):
# Find divs matching your pattern # Find divs matching your pattern
divs = soup.find_all("div", style=re.compile(r"max-width:\s*700px", re.IGNORECASE)) divs = soup.find_all("div", style=re.compile(r"max-width:\s*700px", re.IGNORECASE))
if not divs:
return error_response(request, message="No content found for CLI rendering.")
for div in divs: for div in divs:
# header could be h1/h2/h3 inside the div # header could be h1/h2/h3 inside the div
header_tag = div.find(["h1", "h2", "h3"]) header_tag = div.find(["h1", "h2", "h3"]) # type: ignore
# content is usually one or more <p> tags inside the div # content is usually one or more <p> tags inside the div
p_tags = div.find_all("p") p_tags = div.find_all("p") # type: ignore
if header_tag and p_tags: if header_tag and p_tags:
header_text = header_tag.get_text(strip=True) header_text = header_tag.get_text(strip=True) # type: ignore
content_lines = [] content_lines = []
for p in p_tags: for p in p_tags:
@@ -93,9 +95,9 @@ def render_curl(date=None):
text = p.get_text(strip=False) text = p.get_text(strip=False)
# Extract any <a> links in the paragraph # Extract any <a> links in the paragraph
links = [a.get("href") for a in p.find_all("a", href=True)] links = [a.get("href") for a in p.find_all("a", href=True)] # type: ignore
if links: if links:
text += "\nLinks: " + ", ".join(links) text += "\nLinks: " + ", ".join(links) # type: ignore
content_lines.append(text) content_lines.append(text)
@@ -111,7 +113,7 @@ def render_curl(date=None):
@app.route("/") @app.route("/", strict_slashes=False)
def index(): def index():
if isCLI(request): if isCLI(request):
return render_curl() return render_curl()
@@ -126,8 +128,7 @@ def path(path):
return render(path, handshake_scripts=getHandshakeScript(request.host)) return render(path, handshake_scripts=getHandshakeScript(request.host))
@app.route("/old") @app.route("/old", strict_slashes=False)
@app.route("/old/")
def old(): def old():
now_dates = list_dates()[1:] now_dates = list_dates()[1:]
if isCLI(request): if isCLI(request):

View File

@@ -122,4 +122,10 @@ def sol_donate_post(amount):
return jsonify({"message": "Error: Amount too small"}), 400, SOLANA_HEADERS return jsonify({"message": "Error: Amount too small"}), 400, SOLANA_HEADERS
transaction = create_transaction(sender, amount) transaction = create_transaction(sender, amount)
return jsonify({"message": "Success", "transaction": transaction}), 200, SOLANA_HEADERS 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**"}]}
)

View File

@@ -89,7 +89,7 @@ def callback():
print("Refresh Token:", REFRESH_TOKEN) print("Refresh Token:", REFRESH_TOKEN)
return redirect(url_for("spotify.currently_playing")) return redirect(url_for("spotify.currently_playing"))
@app.route("/") @app.route("/", strict_slashes=False)
@app.route("/playing") @app.route("/playing")
def currently_playing(): def currently_playing():
"""Public endpoint showing your current track.""" """Public endpoint showing your current track."""

View File

@@ -4,6 +4,6 @@ from tools import json_response
app = Blueprint('template', __name__) app = Blueprint('template', __name__)
@app.route("/") @app.route("/", strict_slashes=False)
def index(): def index():
return json_response(request, "Success", 200) return json_response(request, "Success", 200)

View File

@@ -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 import os
app = Blueprint('well-known', __name__, url_prefix='/.well-known') 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()): if os.path.isfile(".well-known/wallets/" + path.upper()):
return redirect("/.well-known/wallets/" + path.upper(), code=302) return redirect("/.well-known/wallets/" + path.upper(), code=302)
return render_template("404.html"), 404 return error_response(request)
@app.route("/nostr.json") @app.route("/nostr.json")

View File

@@ -179,7 +179,6 @@ def serviceWorker():
# region Misc routes # region Misc routes
@app.route("/meet") @app.route("/meet")
@app.route("/meeting") @app.route("/meeting")
@app.route("/appointment") @app.route("/appointment")
@@ -203,13 +202,6 @@ def api_legacy(function):
return redirect(f"/api/v1/{function}", code=301) return redirect(f"/api/v1/{function}", code=301)
return error_response(request, message="404 Not Found", code=404) 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 # endregion
# region Main routes # region Main routes

View File

@@ -9,7 +9,7 @@ Contact [/contact]
Projects [/projects] Projects [/projects]
Tools [/tools] Tools [/tools]
Donate [/donate] Donate [/donate]
API [/api/v1/] API [/api/v1]
─────────────────────────────────────────────── ───────────────────────────────────────────────
 ABOUT ME   ABOUT ME