add: track shared modules, vendor scripts, and update gitignore
- 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
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
"""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
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,12 @@
|
||||
htmx.defineExtension('json-enc', {
|
||||
onEvent: function(name, evt) {
|
||||
if (name === 'htmx:configRequest') {
|
||||
evt.detail.headers['Content-Type'] = 'application/json'
|
||||
}
|
||||
},
|
||||
|
||||
encodeParameters: function(xhr, parameters, elt) {
|
||||
xhr.overrideMimeType('text/json')
|
||||
return (JSON.stringify(parameters))
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user