import os from flask import after_this_request, send_file import db from publish.build_package import build_game_zip from core.flask_app import app @app.route("/game//publish", methods=["POST"]) def publish_game(slug): """Construit et renvoie le zip exécutable autonome du jeu (voir publish/build_package.py) — protégée par la même garde d'accès que toutes les autres routes /game//... (core/auth_guard.py), aucune vérification supplémentaire nécessaire ici.""" zip_path, game_name = build_game_zip(slug) @after_this_request def _cleanup(response): try: os.remove(zip_path) except OSError: pass return response download_name = f"{db.slugify(game_name)}.zip" return send_file(zip_path, as_attachment=True, download_name=download_name, mimetype="application/zip")