21 lines
467 B
Python
21 lines
467 B
Python
"""Shared utility functions for the web server."""
|
|
|
|
from flask import jsonify
|
|
|
|
|
|
def make_response(data, status=200):
|
|
"""Create a JSON response. Returns data directly (no wrapper)."""
|
|
resp = jsonify(data)
|
|
resp.status_code = status
|
|
return resp
|
|
|
|
|
|
def make_error_response(message, status=400):
|
|
"""Create an error response."""
|
|
resp = jsonify({
|
|
"success": False,
|
|
"error": message
|
|
})
|
|
resp.status_code = status
|
|
return resp
|