Added support for configurable buttons to run scripts
This commit is contained in:
parent
51abb3df64
commit
0f3b345c77
7
app/templates/button.html
Normal file
7
app/templates/button.html
Normal file
@ -0,0 +1,7 @@
|
||||
{% extends 'index.html' %}
|
||||
{% block body %}
|
||||
<h2>Output:</h2>
|
||||
<div class="card">
|
||||
<pre>{{ output }}</pre>
|
||||
</div>
|
||||
{% endblock %}
|
@ -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>
|
||||
|
@ -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 = ""
|
||||
|
@ -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' }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user