WebHost: add per-game yaml file downloads
This commit is contained in:
parent
01f1545b3e
commit
88c5ebdd2f
|
@ -1,8 +1,8 @@
|
||||||
from flask import send_file, Response
|
from flask import send_file, Response, render_template
|
||||||
from pony.orm import select
|
from pony.orm import select
|
||||||
|
|
||||||
from Patch import update_patch_data
|
from Patch import update_patch_data
|
||||||
from WebHostLib import app, Slot, Room, Seed
|
from WebHostLib import app, Slot, Room, Seed, cache
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
@app.route("/dl_patch/<suuid:room_id>/<int:patch_id>")
|
@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"
|
fname = name.rsplit("/", 1)[0]+".zip"
|
||||||
else:
|
else:
|
||||||
return "Game download not supported."
|
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)
|
|
@ -0,0 +1,21 @@
|
||||||
|
{% extends 'pageWrapper.html' %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
{% include 'header/grassHeader.html' %}
|
||||||
|
<title>Option Templates (YAML)</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename="styles/markdown.css") }}" />
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.1/showdown.min.js"
|
||||||
|
integrity="sha512-L03kznCrNOfVxOUovR6ESfCz9Gfny7gihUX/huVbQB9zjODtYpxaVtIaAkpetoiyV2eqWbvxMH9fiSv5enX7bw=="
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div>
|
||||||
|
<h1>Option Templates (YAML)</h1>
|
||||||
|
<ul>
|
||||||
|
{% for file in files %}
|
||||||
|
<li><a href="{{ url_for('static', filename="generated/"+file) }}">{{ file }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue