From 2272b1ff12589980c59426391472ef1b43e6e9ae Mon Sep 17 00:00:00 2001 From: Username Date: Sat, 20 Dec 2025 05:19:20 +0100 Subject: [PATCH] add /client endpoint to download fpaste CLI --- Containerfile | 1 + app/api/routes.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Containerfile b/Containerfile index b3f2c58..b6ae11e 100644 --- a/Containerfile +++ b/Containerfile @@ -20,6 +20,7 @@ RUN pip install --no-cache-dir -r requirements.txt gunicorn # Copy application code COPY app/ ./app/ COPY wsgi.py . +COPY fpaste . # Create data directory RUN mkdir -p /app/data && chown -R flaskpaste:flaskpaste /app diff --git a/app/api/routes.py b/app/api/routes.py index c53f5db..51cdfa1 100644 --- a/app/api/routes.py +++ b/app/api/routes.py @@ -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('/')}": "Retrieve paste metadata",