forked from username/flaskpaste
add /client endpoint to download fpaste CLI
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user