add /client endpoint to download fpaste CLI

This commit is contained in:
Username
2025-12-20 05:19:20 +01:00
parent 274648e1f7
commit 2272b1ff12
2 changed files with 17 additions and 0 deletions

View File

@@ -245,6 +245,21 @@ def _get_client_id() -> str | None:
return None
@bp.route("/client", methods=["GET"])
def client():
"""Download the fpaste CLI client."""
import os
client_path = os.path.join(current_app.root_path, "..", "fpaste")
try:
with open(client_path, "r") as f:
content = f.read()
response = Response(content, mimetype="text/x-python")
response.headers["Content-Disposition"] = "attachment; filename=fpaste"
return response
except FileNotFoundError:
return _json_response({"error": "Client not available"}, 404)
@bp.route("/health", methods=["GET"])
def health():
"""Health check endpoint for load balancers and monitoring."""
@@ -288,6 +303,7 @@ def index():
"endpoints": {
f"GET {_url('/')}": "API information",
f"GET {_url('/health')}": "Health check",
f"GET {_url('/client')}": "Download CLI client",
f"GET {_url('/challenge')}": "Get PoW challenge",
f"POST {_url('/')}": "Create paste",
f"GET {_url('/<id>')}": "Retrieve paste metadata",