mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
WebHost: add per-game yaml file downloads
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from flask import send_file, Response
|
||||
from flask import send_file, Response, render_template
|
||||
from pony.orm import select
|
||||
|
||||
from Patch import update_patch_data
|
||||
from WebHostLib import app, Slot, Room, Seed
|
||||
from WebHostLib import app, Slot, Room, Seed, cache
|
||||
import zipfile
|
||||
|
||||
@app.route("/dl_patch/<suuid:room_id>/<int:patch_id>")
|
||||
@@ -68,4 +68,14 @@ def download_slot_file(room_id, player_id: int):
|
||||
fname = name.rsplit("/", 1)[0]+".zip"
|
||||
else:
|
||||
return "Game download not supported."
|
||||
return send_file(io.BytesIO(slot_data.data), as_attachment=True, attachment_filename=fname)
|
||||
return send_file(io.BytesIO(slot_data.data), as_attachment=True, attachment_filename=fname)
|
||||
|
||||
@app.route("/templates")
|
||||
@cache.cached()
|
||||
def list_yaml_templates():
|
||||
import os
|
||||
files = []
|
||||
for file in os.scandir(os.path.join(app.static_folder, "generated")):
|
||||
if file.is_file() and file.name.endswith(".yaml"):
|
||||
files.append(file.name)
|
||||
return render_template("templates.html", files=files)
|
Reference in New Issue
Block a user