28 lines
680 B
Python
28 lines
680 B
Python
#!/usr/bin/env python3
|
|
|
|
from os import environ
|
|
from flask import Flask, request
|
|
from subprocess import check_output, CalledProcessError
|
|
import json
|
|
from sys import stderr
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route('/<strategy>', methods=['POST'])
|
|
def build(strategy):
|
|
try:
|
|
return check_output([
|
|
f"{environ['STRATEGIES_DIR']}/{strategy}",
|
|
json.dumps(request.get_json(), sort_keys=True, indent=4),
|
|
json.dumps(request.args.to_dict()),
|
|
])
|
|
except CalledProcessError as error:
|
|
print(error.stdout, file=stderr)
|
|
print(error.stderr, file=stderr)
|
|
|
|
raise error
|
|
|
|
@app.route('/status')
|
|
def status():
|
|
return 'OK'
|
|
|