- Split app.py into routes + ascii_engine.py (stdlib-only procedural generation: figlet banners, creatures, patterns, scenes, classics) - API: /api/random?category=..., /api/categories, richer JSON payload - New frontend: templates/index.html + static/ (vanilla JS/CSS) - 4 themes (graphite/paper/phosphor/amber), localStorage persist, no-flash boot, prefers-color-scheme default - Scramble-resolve art transition, reduced-motion support - Responsive: rail collapses to chips <760px, art auto-fits width - Fix grid blowout on mobile (min-width: 0 on stage children) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
43 lines
920 B
Python
43 lines
920 B
Python
from flask import Flask, jsonify, render_template, request
|
|
|
|
import ascii_engine
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
@app.route("/")
|
|
def index():
|
|
piece = ascii_engine.generate()
|
|
return render_template(
|
|
"index.html",
|
|
piece=piece,
|
|
categories=ascii_engine.category_list(),
|
|
)
|
|
|
|
|
|
@app.route("/api/random")
|
|
def api_random():
|
|
category = request.args.get("category")
|
|
try:
|
|
piece = ascii_engine.generate(category)
|
|
except KeyError:
|
|
return (
|
|
jsonify(
|
|
{
|
|
"error": f"unknown category '{category}'",
|
|
"categories": ascii_engine.category_list(),
|
|
}
|
|
),
|
|
400,
|
|
)
|
|
return jsonify(piece)
|
|
|
|
|
|
@app.route("/api/categories")
|
|
def api_categories():
|
|
return jsonify({"categories": ascii_engine.category_list()})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.run(host="0.0.0.0", port=5000)
|