Add 5 new tools: QR-Code, Markdown, Color Converter, JSON Formatter, Regex Tester
- backend/tools/qrcode_gen.py: POST /api/qrcode/generate, returns base64 PNG (qrcode[pil]) - backend/tools/markdown_tool.py: POST /api/markdown/render, extensions: tables/fenced_code/nl2br - backend/tools/colorconverter.py: POST /api/color/convert, HEX/RGB/HSL via colorsys (no deps) - backend/tools/jsonformatter.py: POST /api/json/format, returns formatted JSON with line/col errors - backend/tools/regextester.py: POST /api/regex/test, flags i/m/s, returns matches with positions - QrCodeTool.jsx: generate + download PNG button - MarkdownTool.jsx: split editor/preview, debounce 500ms, white preview bg - ColorConverterTool.jsx: color swatch preview, per-format copy buttons - JsonFormatterTool.jsx: indent toggle 2/4, pre result box with copy - RegexTesterTool.jsx: debounce 400ms, yellow match highlighting, flag checkboxes - All blueprints registered in app.py; qrcode[pil] + markdown added to requirements.txt Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from flask import Blueprint, request, jsonify
|
||||
import json
|
||||
from util.logger import logger
|
||||
from auth.token import verify_token
|
||||
|
||||
json_formatter_blueprint = Blueprint('json_formatter_tool', __name__)
|
||||
|
||||
|
||||
@json_formatter_blueprint.route('/api/json/format', methods=['POST'])
|
||||
def format_json():
|
||||
user = verify_token()
|
||||
if not user:
|
||||
return jsonify({"message": "Nicht autorisiert"}), 401
|
||||
try:
|
||||
data = request.get_json(silent=True) or {}
|
||||
text = data.get("text", "")
|
||||
indent = int(data.get("indent", 2))
|
||||
|
||||
parsed = json.loads(text)
|
||||
formatted = json.dumps(parsed, indent=indent, ensure_ascii=False)
|
||||
return jsonify({"result": formatted})
|
||||
except json.JSONDecodeError as e:
|
||||
return jsonify({"message": f"JSON-Fehler in Zeile {e.lineno}, Spalte {e.colno}: {e.msg}"}), 400
|
||||
except Exception as e:
|
||||
logger.error(f"Fehler JSON-Formatter: {e}")
|
||||
return jsonify({"message": "Fehler beim Formatieren"}), 500
|
||||
Reference in New Issue
Block a user