- Bake the commit SHA into the image (GIT_SHA build arg) and serve it at /version, so a deploy can be verified end to end. This repo is the dockerloid deploy test service. - cssnr/portainer-stack-deploy-action@v1 reads `endpoint` and `pull`; `endpoint_id` / `pull_image` were silently ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.0 KiB
Python
50 lines
1.0 KiB
Python
import os
|
|
|
|
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("/version")
|
|
def version():
|
|
return jsonify(gitSha=os.environ.get("GIT_SHA", "unknown"))
|
|
|
|
|
|
@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)
|