f81be96e59
- lib/common.py: shared run/load_json/save_json utilities - webui/api/common.py: _ok/_error response helpers - webui/static/htmx.min.js, json-enc.js: vendored frontend deps - scripts/update-vendor.sh: frontend vendor updater - vendor/acme.sh: bundled ACME client - .gitignore: add .playwright-mcp/ and opencode.json.pwenv
19 lines
509 B
Python
19 lines
509 B
Python
"""Shared API response helpers.
|
|
|
|
Used by all API blueprints to produce consistent JSON responses
|
|
per the API response contract: ``{"ok": true, "data": <value>}`` /
|
|
``{"ok": false, "error": "msg"}``.
|
|
"""
|
|
|
|
from flask import jsonify
|
|
|
|
|
|
def _ok(data=None):
|
|
"""Return a success JSON response."""
|
|
return jsonify({"ok": True, "data": data})
|
|
|
|
|
|
def _error(msg: str, code: int = 400):
|
|
"""Return an error JSON response with the given HTTP status code."""
|
|
return jsonify({"ok": False, "error": msg}), code
|