Added support for configurable buttons to run scripts

This commit is contained in:
Silvan Calarco 2022-10-03 15:04:35 +02:00
parent 51abb3df64
commit 0f3b345c77
4 changed files with 25 additions and 2 deletions

View File

@ -0,0 +1,7 @@
{% extends 'index.html' %}
{% block body %}
<h2>Output:</h2>
<div class="card">
<pre>{{ output }}</pre>
</div>
{% endblock %}

View File

@ -16,9 +16,15 @@
<div class="container-fluid">
<h2>Welcome To WebDist</h2>
<a href="/">Home</a> | <a href="/latest">Latest packages</a>
<hr>
{% block body %}
<pre>{{ output }}</pre>
{% for button in config['BUTTONS'] %}
<div class="col">
<a href="button/{{ button }}" class="btn btn-warning" role="button">{{ config['BUTTONS'][button]['text'] }}</a>
</div>
</hr>
{% endfor %}
{% endblock %}
</div>

View File

@ -75,6 +75,13 @@ def _latest():
return render_template("latest.html", data=data)
@app.route("/button/<name>")
def _button(name):
script = app.config['BUTTONS'][name]['script']
output = subprocess.check_output([script])
return render_template("button.html",output=output.decode())
@app.route("/query/<qs>")
def _query(qs):
body = ""

View File

@ -5,3 +5,6 @@ REPOS = {
'openmamba-rolling': { 'dbname': 'devel', 'path': '/var/webbuild/db/' },
'openmamba-testing': { 'dbname': 'devel-makedist', 'path': '/var/webbuild/db/' },
}
BUTTONS = {
'sample_button': { 'text':"This is a sample button", 'script': '/bin/true' }
}