Files
adlist_mikrotik/adlist/pages.py
T
2026-10-09 10:53:10 +02:00

28 lines
809 B
Python

"""Public page and consistent HTTP error rendering."""
from datetime import datetime
from flask import request, render_template, Response, jsonify, current_app
from adlist import services
import config
def favicon():
return current_app.send_static_file("favicon.svg")
def index():
recent_links = services.get_recent_links()
return render_template(
"form.html",
recent_links=recent_links,
client_ip=services.get_client_ip(),
cache_days=config.CACHE_S_MAXAGE // 86400,
)
def handle_errors(error):
status = getattr(error, "code", 500)
try:
return render_template("error.html", error=error, code=status), status
except Exception:
return jsonify({"error": getattr(error, "description", "Unexpected error"), "code": status}), status