-
Notifications
You must be signed in to change notification settings - Fork 8
/
web_ui.py
43 lines (29 loc) · 933 Bytes
/
web_ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import argparse
import sys
import yaml
from subprocess import Popen, STDOUT
from flask import Flask, request, abort
parser = argparse.ArgumentParser()
parser.add_argument("--config", help="Sets the config file", default="config.yml")
args = parser.parse_args()
config = {}
with open(args.config, "r") as f:
try:
config = yaml.safe_load(f)
except yaml.YAMLError as e:
print(e)
sys.exit(1)
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello stranger!'
@app.route('/trigger/release')
def trigger_release():
if request.args.get('api_key') != config['webui']['key']:
abort(403)
args = [request.args['version']]
if 'tag_name' in request.args and request.args['tag_name'] != '':
args.append(request.args['tag_name'])
Popen([sys.executable, 'release.py'] + args, stdout=open('release.log', 'w'), stderr=STDOUT)
return 'OK'
application = app