devkit / app /tools /git_narrator /routes.py
Mohammed AL Sarraj
initial deploy
950dcd2
raw
history blame contribute delete
701 Bytes
"""Git Narrator routes."""
from flask import Blueprint, render_template, request, jsonify
from .narrator import narrate
bp = Blueprint("git_narrator", __name__, template_folder="templates")
@bp.route("/")
def index():
return render_template("git_narrator/index.html")
@bp.route("/api/narrate", methods=["POST"])
def api_narrate():
body = request.get_json(silent=True) or {}
raw = (body.get("content") or "").strip()
if not raw:
return jsonify({"error": "content is required (GitHub URL or git log text)"}), 400
if len(raw) < 10:
return jsonify({"error": "Input too short — paste a URL or git log"}), 400
result = narrate(raw)
return jsonify(result)