feat: Refactor blueprints to make them easier to import
All checks were successful
Build Docker / BuildImage (push) Successful in 47s
All checks were successful
Build Docker / BuildImage (push) Successful in 47s
This commit is contained in:
@@ -3,10 +3,10 @@ import os
|
|||||||
from cloudflare import Cloudflare
|
from cloudflare import Cloudflare
|
||||||
from tools import json_response
|
from tools import json_response
|
||||||
|
|
||||||
acme_bp = Blueprint('acme', __name__)
|
app = Blueprint('acme', __name__)
|
||||||
|
|
||||||
|
|
||||||
@acme_bp.route("/hnsdoh-acme", methods=["POST"])
|
@app.route("/hnsdoh-acme", methods=["POST"])
|
||||||
def post():
|
def post():
|
||||||
# Get the TXT record from the request
|
# Get the TXT record from the request
|
||||||
if not request.is_json or not request.json:
|
if not request.is_json or not request.json:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import requests
|
|||||||
import re
|
import re
|
||||||
from mail import sendEmail
|
from mail import sendEmail
|
||||||
from tools import getClientIP, getGitCommit, json_response, parse_date, get_tools_data
|
from tools import getClientIP, getGitCommit, json_response, parse_date, get_tools_data
|
||||||
from blueprints.sol import sol_bp
|
from blueprints import sol
|
||||||
from dateutil import parser as date_parser
|
from dateutil import parser as date_parser
|
||||||
from blueprints.spotify import get_spotify_track
|
from blueprints.spotify import get_spotify_track
|
||||||
|
|
||||||
@@ -17,9 +17,9 @@ HTTP_NOT_FOUND = 404
|
|||||||
HTTP_UNSUPPORTED_MEDIA = 415
|
HTTP_UNSUPPORTED_MEDIA = 415
|
||||||
HTTP_SERVER_ERROR = 500
|
HTTP_SERVER_ERROR = 500
|
||||||
|
|
||||||
api_bp = Blueprint('api', __name__)
|
app = Blueprint('api', __name__, url_prefix='/api/v1')
|
||||||
# Register solana blueprint
|
# Register solana blueprint
|
||||||
api_bp.register_blueprint(sol_bp)
|
app.register_blueprint(sol.app)
|
||||||
|
|
||||||
# Load configuration
|
# Load configuration
|
||||||
NC_CONFIG = requests.get(
|
NC_CONFIG = requests.get(
|
||||||
@@ -30,8 +30,8 @@ if 'time-zone' not in NC_CONFIG:
|
|||||||
NC_CONFIG['time-zone'] = 10
|
NC_CONFIG['time-zone'] = 10
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route("/")
|
@app.route("/")
|
||||||
@api_bp.route("/help")
|
@app.route("/help")
|
||||||
def help():
|
def help():
|
||||||
"""Provide API documentation and help."""
|
"""Provide API documentation and help."""
|
||||||
return jsonify({
|
return jsonify({
|
||||||
@@ -57,18 +57,18 @@ def help():
|
|||||||
"status": HTTP_OK
|
"status": HTTP_OK
|
||||||
})
|
})
|
||||||
|
|
||||||
@api_bp.route("/status")
|
@app.route("/status")
|
||||||
@api_bp.route("/ping")
|
@app.route("/ping")
|
||||||
def status():
|
def status():
|
||||||
return json_response(request, "200 OK", HTTP_OK)
|
return json_response(request, "200 OK", HTTP_OK)
|
||||||
|
|
||||||
@api_bp.route("/version")
|
@app.route("/version")
|
||||||
def version():
|
def version():
|
||||||
"""Get the current version of the website."""
|
"""Get the current version of the website."""
|
||||||
return jsonify({"version": getGitCommit()})
|
return jsonify({"version": getGitCommit()})
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route("/time")
|
@app.route("/time")
|
||||||
def time():
|
def time():
|
||||||
"""Get the current time in the configured timezone."""
|
"""Get the current time in the configured timezone."""
|
||||||
timezone_offset = datetime.timedelta(hours=NC_CONFIG["time-zone"])
|
timezone_offset = datetime.timedelta(hours=NC_CONFIG["time-zone"])
|
||||||
@@ -84,7 +84,7 @@ def time():
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route("/timezone")
|
@app.route("/timezone")
|
||||||
def timezone():
|
def timezone():
|
||||||
"""Get the current timezone setting."""
|
"""Get the current timezone setting."""
|
||||||
return jsonify({
|
return jsonify({
|
||||||
@@ -94,7 +94,7 @@ def timezone():
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route("/message")
|
@app.route("/message")
|
||||||
def message():
|
def message():
|
||||||
"""Get the message from the configuration."""
|
"""Get the message from the configuration."""
|
||||||
return jsonify({
|
return jsonify({
|
||||||
@@ -104,7 +104,7 @@ def message():
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route("/ip")
|
@app.route("/ip")
|
||||||
def ip():
|
def ip():
|
||||||
"""Get the client's IP address."""
|
"""Get the client's IP address."""
|
||||||
return jsonify({
|
return jsonify({
|
||||||
@@ -113,7 +113,7 @@ def ip():
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route("/email", methods=["POST"])
|
@app.route("/email", methods=["POST"])
|
||||||
def email_post():
|
def email_post():
|
||||||
"""Send an email via the API (requires API key)."""
|
"""Send an email via the API (requires API key)."""
|
||||||
# Verify json
|
# Verify json
|
||||||
@@ -135,7 +135,7 @@ def email_post():
|
|||||||
return sendEmail(data)
|
return sendEmail(data)
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route("/project")
|
@app.route("/project")
|
||||||
def project():
|
def project():
|
||||||
"""Get information about the current git project."""
|
"""Get information about the current git project."""
|
||||||
gitinfo = {
|
gitinfo = {
|
||||||
@@ -168,7 +168,7 @@ def project():
|
|||||||
"status": HTTP_OK
|
"status": HTTP_OK
|
||||||
})
|
})
|
||||||
|
|
||||||
@api_bp.route("/tools")
|
@app.route("/tools")
|
||||||
def tools():
|
def tools():
|
||||||
"""Get a list of tools used by Nathan Woodburn."""
|
"""Get a list of tools used by Nathan Woodburn."""
|
||||||
try:
|
try:
|
||||||
@@ -184,7 +184,7 @@ def tools():
|
|||||||
|
|
||||||
return json_response(request, {"tools": tools}, HTTP_OK)
|
return json_response(request, {"tools": tools}, HTTP_OK)
|
||||||
|
|
||||||
@api_bp.route("/playing")
|
@app.route("/playing")
|
||||||
def playing():
|
def playing():
|
||||||
"""Get the currently playing Spotify track."""
|
"""Get the currently playing Spotify track."""
|
||||||
track_info = get_spotify_track()
|
track_info = get_spotify_track()
|
||||||
@@ -193,7 +193,7 @@ def playing():
|
|||||||
return json_response(request, {"spotify": track_info}, HTTP_OK)
|
return json_response(request, {"spotify": track_info}, HTTP_OK)
|
||||||
|
|
||||||
|
|
||||||
@api_bp.route("/headers")
|
@app.route("/headers")
|
||||||
def headers():
|
def headers():
|
||||||
"""Get the request headers."""
|
"""Get the request headers."""
|
||||||
headers = dict(request.headers)
|
headers = dict(request.headers)
|
||||||
@@ -216,7 +216,7 @@ def headers():
|
|||||||
"status": HTTP_OK
|
"status": HTTP_OK
|
||||||
})
|
})
|
||||||
|
|
||||||
@api_bp.route("/page_date")
|
@app.route("/page_date")
|
||||||
def page_date():
|
def page_date():
|
||||||
url = request.args.get("url")
|
url = request.args.get("url")
|
||||||
if not url:
|
if not url:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from bs4 import BeautifulSoup
|
|||||||
import re
|
import re
|
||||||
from tools import isCLI, getClientIP, getHandshakeScript
|
from tools import isCLI, getClientIP, getHandshakeScript
|
||||||
|
|
||||||
blog_bp = Blueprint('blog', __name__)
|
app = Blueprint('blog', __name__, url_prefix='/blog')
|
||||||
|
|
||||||
|
|
||||||
def list_page_files():
|
def list_page_files():
|
||||||
@@ -108,7 +108,7 @@ def render_home(handshake_scripts: str | None = None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@blog_bp.route("/")
|
@app.route("/")
|
||||||
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))
|
||||||
@@ -129,7 +129,7 @@ def index():
|
|||||||
}), 200
|
}), 200
|
||||||
|
|
||||||
|
|
||||||
@blog_bp.route("/<path:path>")
|
@app.route("/<path:path>")
|
||||||
def path(path):
|
def path(path):
|
||||||
if not isCLI(request):
|
if not isCLI(request):
|
||||||
return render_page(path, handshake_scripts=getHandshakeScript(request.host))
|
return render_page(path, handshake_scripts=getHandshakeScript(request.host))
|
||||||
@@ -152,7 +152,7 @@ def path(path):
|
|||||||
}), 200
|
}), 200
|
||||||
|
|
||||||
|
|
||||||
@blog_bp.route("/<path:path>.md")
|
@app.route("/<path:path>.md")
|
||||||
def path_md(path):
|
def path_md(path):
|
||||||
if not os.path.exists(f"data/blog/{path}.md"):
|
if not os.path.exists(f"data/blog/{path}.md"):
|
||||||
return render_template("404.html"), 404
|
return render_template("404.html"), 404
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import os
|
|||||||
from tools import getHandshakeScript
|
from tools import getHandshakeScript
|
||||||
|
|
||||||
# Create blueprint
|
# Create blueprint
|
||||||
now_bp = Blueprint('now', __name__)
|
app = Blueprint('now', __name__, url_prefix='/now')
|
||||||
|
|
||||||
|
|
||||||
def list_page_files():
|
def list_page_files():
|
||||||
@@ -51,18 +51,18 @@ def render(date, handshake_scripts=None):
|
|||||||
return render_template(f"now/{date}.html", DATE=date_formatted, handshake_scripts=handshake_scripts)
|
return render_template(f"now/{date}.html", DATE=date_formatted, handshake_scripts=handshake_scripts)
|
||||||
|
|
||||||
|
|
||||||
@now_bp.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
return render_latest(handshake_scripts=getHandshakeScript(request.host))
|
return render_latest(handshake_scripts=getHandshakeScript(request.host))
|
||||||
|
|
||||||
|
|
||||||
@now_bp.route("/<path:path>")
|
@app.route("/<path:path>")
|
||||||
def path(path):
|
def path(path):
|
||||||
return render(path, handshake_scripts=getHandshakeScript(request.host))
|
return render(path, handshake_scripts=getHandshakeScript(request.host))
|
||||||
|
|
||||||
|
|
||||||
@now_bp.route("/old")
|
@app.route("/old")
|
||||||
@now_bp.route("/old/")
|
@app.route("/old/")
|
||||||
def old():
|
def old():
|
||||||
now_dates = list_dates()[1:]
|
now_dates = list_dates()[1:]
|
||||||
html = '<ul class="list-group">'
|
html = '<ul class="list-group">'
|
||||||
@@ -80,9 +80,9 @@ def old():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@now_bp.route("/now.rss")
|
@app.route("/now.rss")
|
||||||
@now_bp.route("/now.xml")
|
@app.route("/now.xml")
|
||||||
@now_bp.route("/rss.xml")
|
@app.route("/rss.xml")
|
||||||
def rss():
|
def rss():
|
||||||
host = "https://" + request.host
|
host = "https://" + request.host
|
||||||
if ":" in request.host:
|
if ":" in request.host:
|
||||||
@@ -99,7 +99,7 @@ def rss():
|
|||||||
return make_response(rss, 200, {"Content-Type": "application/rss+xml"})
|
return make_response(rss, 200, {"Content-Type": "application/rss+xml"})
|
||||||
|
|
||||||
|
|
||||||
@now_bp.route("/now.json")
|
@app.route("/now.json")
|
||||||
def json():
|
def json():
|
||||||
now_pages = list_page_files()
|
now_pages = list_page_files()
|
||||||
host = "https://" + request.host
|
host = "https://" + request.host
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ from flask import Blueprint, make_response, request
|
|||||||
from tools import error_response
|
from tools import error_response
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
podcast_bp = Blueprint('podcast', __name__)
|
app = Blueprint('podcast', __name__)
|
||||||
|
|
||||||
@podcast_bp.route("/ID1")
|
@app.route("/ID1")
|
||||||
def index():
|
def index():
|
||||||
# Proxy to ID1 url
|
# Proxy to ID1 url
|
||||||
req = requests.get("https://podcasts.c.woodburn.au/ID1")
|
req = requests.get("https://podcasts.c.woodburn.au/ID1")
|
||||||
@@ -16,7 +16,7 @@ def index():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@podcast_bp.route("/ID1/")
|
@app.route("/ID1/")
|
||||||
def contents():
|
def contents():
|
||||||
# Proxy to ID1 url
|
# Proxy to ID1 url
|
||||||
req = requests.get("https://podcasts.c.woodburn.au/ID1/")
|
req = requests.get("https://podcasts.c.woodburn.au/ID1/")
|
||||||
@@ -27,7 +27,7 @@ def contents():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@podcast_bp.route("/ID1/<path:path>")
|
@app.route("/ID1/<path:path>")
|
||||||
def path(path):
|
def path(path):
|
||||||
# Proxy to ID1 url
|
# Proxy to ID1 url
|
||||||
req = requests.get("https://podcasts.c.woodburn.au/ID1/" + path)
|
req = requests.get("https://podcasts.c.woodburn.au/ID1/" + path)
|
||||||
@@ -38,7 +38,7 @@ def path(path):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@podcast_bp.route("/ID1.xml")
|
@app.route("/ID1.xml")
|
||||||
def xml():
|
def xml():
|
||||||
# Proxy to ID1 url
|
# Proxy to ID1 url
|
||||||
req = requests.get("https://podcasts.c.woodburn.au/ID1.xml")
|
req = requests.get("https://podcasts.c.woodburn.au/ID1.xml")
|
||||||
@@ -49,7 +49,7 @@ def xml():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@podcast_bp.route("/podsync.opml")
|
@app.route("/podsync.opml")
|
||||||
def podsync():
|
def podsync():
|
||||||
req = requests.get("https://podcasts.c.woodburn.au/podsync.opml")
|
req = requests.get("https://podcasts.c.woodburn.au/podsync.opml")
|
||||||
if req.status_code != 200:
|
if req.status_code != 200:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import binascii
|
|||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
|
|
||||||
sol_bp = Blueprint('sol', __name__)
|
app = Blueprint('sol', __name__)
|
||||||
|
|
||||||
SOLANA_HEADERS = {
|
SOLANA_HEADERS = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -55,7 +55,7 @@ def get_solana_address() -> str:
|
|||||||
raise ValueError("SOLANA_ADDRESS is not set. Please ensure the .well-known/wallets/SOL file exists and contains a valid address.")
|
raise ValueError("SOLANA_ADDRESS is not set. Please ensure the .well-known/wallets/SOL file exists and contains a valid address.")
|
||||||
return str(SOLANA_ADDRESS)
|
return str(SOLANA_ADDRESS)
|
||||||
|
|
||||||
@sol_bp.route("/donate", methods=["GET", "OPTIONS"])
|
@app.route("/donate", methods=["GET", "OPTIONS"])
|
||||||
def sol_donate():
|
def sol_donate():
|
||||||
data = {
|
data = {
|
||||||
"icon": "https://nathan.woodburn.au/assets/img/profile.png",
|
"icon": "https://nathan.woodburn.au/assets/img/profile.png",
|
||||||
@@ -90,7 +90,7 @@ def sol_donate():
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@sol_bp.route("/donate/<amount>")
|
@app.route("/donate/<amount>")
|
||||||
def sol_donate_amount(amount):
|
def sol_donate_amount(amount):
|
||||||
data = {
|
data = {
|
||||||
"icon": "https://nathan.woodburn.au/assets/img/profile.png",
|
"icon": "https://nathan.woodburn.au/assets/img/profile.png",
|
||||||
@@ -101,7 +101,7 @@ def sol_donate_amount(amount):
|
|||||||
return jsonify(data), 200, SOLANA_HEADERS
|
return jsonify(data), 200, SOLANA_HEADERS
|
||||||
|
|
||||||
|
|
||||||
@sol_bp.route("/donate/<amount>", methods=["POST"])
|
@app.route("/donate/<amount>", methods=["POST"])
|
||||||
def sol_donate_post(amount):
|
def sol_donate_post(amount):
|
||||||
|
|
||||||
if not request.json:
|
if not request.json:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import requests
|
|||||||
import time
|
import time
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
spotify_bp = Blueprint('spotify', __name__)
|
app = Blueprint('spotify', __name__, url_prefix='/spotify')
|
||||||
|
|
||||||
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_ID")
|
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_ID")
|
||||||
CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRET")
|
CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRET")
|
||||||
@@ -48,7 +48,7 @@ def refresh_access_token():
|
|||||||
TOKEN_EXPIRES = time.time() + token_info.get("expires_in", 3600)
|
TOKEN_EXPIRES = time.time() + token_info.get("expires_in", 3600)
|
||||||
return ACCESS_TOKEN
|
return ACCESS_TOKEN
|
||||||
|
|
||||||
@spotify_bp.route("/login")
|
@app.route("/login")
|
||||||
def login():
|
def login():
|
||||||
auth_query = (
|
auth_query = (
|
||||||
f"{SPOTIFY_AUTH_URL}?response_type=code&client_id={CLIENT_ID}"
|
f"{SPOTIFY_AUTH_URL}?response_type=code&client_id={CLIENT_ID}"
|
||||||
@@ -56,7 +56,7 @@ def login():
|
|||||||
)
|
)
|
||||||
return redirect(auth_query)
|
return redirect(auth_query)
|
||||||
|
|
||||||
@spotify_bp.route("/callback")
|
@app.route("/callback")
|
||||||
def callback():
|
def callback():
|
||||||
code = request.args.get("code")
|
code = request.args.get("code")
|
||||||
if not code:
|
if not code:
|
||||||
@@ -89,8 +89,8 @@ 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"))
|
||||||
|
|
||||||
@spotify_bp.route("/")
|
@app.route("/")
|
||||||
@spotify_bp.route("/currently-playing")
|
@app.route("/playing")
|
||||||
def currently_playing():
|
def currently_playing():
|
||||||
"""Public endpoint showing your current track."""
|
"""Public endpoint showing your current track."""
|
||||||
track = get_spotify_track()
|
track = get_spotify_track()
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
from flask import Blueprint, request
|
from flask import Blueprint, request
|
||||||
from tools import json_response
|
from tools import json_response
|
||||||
|
|
||||||
template_bp = Blueprint('template', __name__)
|
app = Blueprint('template', __name__)
|
||||||
|
|
||||||
|
|
||||||
@template_bp.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
return json_response(request, "Success", 200)
|
return json_response(request, "Success", 200)
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
from flask import Blueprint, render_template, make_response, request, jsonify, send_from_directory, redirect
|
from flask import Blueprint, render_template, make_response, request, jsonify, send_from_directory, redirect
|
||||||
import os
|
import os
|
||||||
|
|
||||||
wk_bp = Blueprint('well-known', __name__)
|
app = Blueprint('well-known', __name__, url_prefix='/.well-known')
|
||||||
|
|
||||||
|
|
||||||
@wk_bp.route("/<path:path>")
|
@app.route("/<path:path>")
|
||||||
def index(path):
|
def index(path):
|
||||||
return send_from_directory(".well-known", path)
|
return send_from_directory(".well-known", path)
|
||||||
|
|
||||||
|
|
||||||
@wk_bp.route("/wallets/<path:path>")
|
@app.route("/wallets/<path:path>")
|
||||||
def wallets(path):
|
def wallets(path):
|
||||||
if path[0] == "." and 'proof' not in path:
|
if path[0] == "." and 'proof' not in path:
|
||||||
return send_from_directory(
|
return send_from_directory(
|
||||||
@@ -28,7 +28,7 @@ def wallets(path):
|
|||||||
return render_template("404.html"), 404
|
return render_template("404.html"), 404
|
||||||
|
|
||||||
|
|
||||||
@wk_bp.route("/nostr.json")
|
@app.route("/nostr.json")
|
||||||
def nostr():
|
def nostr():
|
||||||
# Get name parameter
|
# Get name parameter
|
||||||
name = request.args.get("name")
|
name = request.args.get("name")
|
||||||
@@ -50,7 +50,7 @@ def nostr():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@wk_bp.route("/xrp-ledger.toml")
|
@app.route("/xrp-ledger.toml")
|
||||||
def xrp():
|
def xrp():
|
||||||
# Create a response with the xrp-ledger.toml file
|
# Create a response with the xrp-ledger.toml file
|
||||||
with open(".well-known/xrp-ledger.toml") as file:
|
with open(".well-known/xrp-ledger.toml") as file:
|
||||||
|
|||||||
21
server.py
21
server.py
@@ -19,13 +19,7 @@ from qrcode.constants import ERROR_CORRECT_L, ERROR_CORRECT_H
|
|||||||
from ansi2html import Ansi2HTMLConverter
|
from ansi2html import Ansi2HTMLConverter
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
# Import blueprints
|
# Import blueprints
|
||||||
from blueprints.now import now_bp
|
from blueprints import now, blog, wellknown, api, podcast, acme, spotify
|
||||||
from blueprints.blog import blog_bp
|
|
||||||
from blueprints.wellknown import wk_bp
|
|
||||||
from blueprints.api import api_bp
|
|
||||||
from blueprints.podcast import podcast_bp
|
|
||||||
from blueprints.acme import acme_bp
|
|
||||||
from blueprints.spotify import spotify_bp
|
|
||||||
from tools import isCLI, isCrawler, getAddress, getFilePath, error_response, getClientIP, json_response, getHandshakeScript, get_tools_data
|
from tools import isCLI, isCrawler, getAddress, getFilePath, error_response, getClientIP, json_response, getHandshakeScript, get_tools_data
|
||||||
from curl import curl_response
|
from curl import curl_response
|
||||||
|
|
||||||
@@ -33,13 +27,9 @@ app = Flask(__name__)
|
|||||||
CORS(app)
|
CORS(app)
|
||||||
|
|
||||||
# Register blueprints
|
# Register blueprints
|
||||||
app.register_blueprint(now_bp, url_prefix='/now')
|
for module in [now, blog, wellknown, api, podcast, acme, spotify]:
|
||||||
app.register_blueprint(blog_bp, url_prefix='/blog')
|
app.register_blueprint(module.app)
|
||||||
app.register_blueprint(wk_bp, url_prefix='/.well-known')
|
|
||||||
app.register_blueprint(api_bp, url_prefix='/api/v1')
|
|
||||||
app.register_blueprint(podcast_bp)
|
|
||||||
app.register_blueprint(acme_bp)
|
|
||||||
app.register_blueprint(spotify_bp, url_prefix='/spotify')
|
|
||||||
|
|
||||||
dotenv.load_dotenv()
|
dotenv.load_dotenv()
|
||||||
|
|
||||||
@@ -54,7 +44,8 @@ RATE_LIMIT_WINDOW = 3600 # 1 hour in seconds
|
|||||||
|
|
||||||
RESTRICTED_ROUTES = ["ascii"]
|
RESTRICTED_ROUTES = ["ascii"]
|
||||||
REDIRECT_ROUTES = {
|
REDIRECT_ROUTES = {
|
||||||
"contact": "/#contact"
|
"contact": "/#contact",
|
||||||
|
"old": "/now/old"
|
||||||
}
|
}
|
||||||
DOWNLOAD_ROUTES = {
|
DOWNLOAD_ROUTES = {
|
||||||
"pgp": "data/nathanwoodburn.asc"
|
"pgp": "data/nathanwoodburn.asc"
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ let currentTrackId = null;
|
|||||||
// --- Spotify fetch ---
|
// --- Spotify fetch ---
|
||||||
async function updateSpotifyWidget() {
|
async function updateSpotifyWidget() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/spotify/');
|
const res = await fetch('/api/v1/playing');
|
||||||
if (!res.ok) return;
|
if (!res.ok) return;
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
|||||||
Reference in New Issue
Block a user