commit fbfea95730eeace8160523d402d2fd69f63516da Author: Daniel Swanson Date: Wed Jun 30 12:56:09 2021 -0500 display a page diff --git a/.editorconfig b/.editorconfig index 44d90e1..10f247d 100755 --- a/.editorconfig +++ b/.editorconfig @@ -5,6 +5,6 @@ root = yes charset = utf-8 end_of_line = lf indent_size = 4 -indent_style = tab +indent_style = space insert_final_newline = true trim_trailing_whitespace = true diff --git a/regtest.py b/regtest.py index df468b4..9f012d7 100644 --- a/regtest.py +++ b/regtest.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 from functools import partial +from http import HTTPStatus import http.server import json import os @@ -12,26 +13,45 @@ class CallbackRequestHandler(http.server.SimpleHTTPRequestHandler): parts = urllib.parse.urlsplit(self.path) if parts.path.strip('/') != 'callback': return super().do_GET() + else: + params = urllib.parse.parse_qs(parts.query) + self.do_callback(params) + + def do_POST(self): + ln = int(self.headers['Content-Length']) + data = self.rfile.read(ln) + self.do_callback(urllib.parse.parse_qs(data.decode('utf-8'))) - params = urllib.parse.parse_qs(parts.query) + def do_callback(self, params): + print(params) if 'a' not in params: resp = 'Parameter a must be passed!' self.send_response(HTTPStatus.OK) self.send_header("Content-type", 'text/plain') self.send_header("Content-Length", len(resp)) self.end_headers() - self.wfile.write(resp) + self.wfile.write(resp.encode('utf-8')) return status = HTTPStatus.OK resp = {} - if params['a'] == 'blah': - pass + if params['a'][0] == 'init': + resp['folder'] = 'nowhere' + resp['corpora'] = ['blah', 'bloop', 'blarg'] + elif params['a'][0] == 'load': + try: + resp = cb_load(params['p'][0]) + except: + resp['error'] = 'Current state is missing or invalid. You will need to run the regression test for all corpora.' + elif params['a'][0] == 'run': + good, out = test_run(params.get('c', ['*'])[0]) + resp['good'] = good + resp['output'] = output else: resp['error'] = 'unknown value for parameter a' - rstr = json.dumps(resp) + rstr = json.dumps(resp).encode('utf-8') self.send_response(status) self.send_header('Content-type', 'application/json') self.send_header('Content-Length', len(rstr)) diff --git a/static/index.html b/static/index.html index 753ffc2..22c1a08 100644 --- a/static/index.html +++ b/static/index.html @@ -5,13 +5,13 @@ …loading… - - - - + + + + - - + + diff --git a/static/regtest.js b/static/regtest.js index da1ee44..b11ddeb 100644 --- a/static/regtest.js +++ b/static/regtest.js @@ -479,7 +479,7 @@ function update_counts() { } function cb_init(rv) { - let txt = 'Regtest: -b '+rv.binary+' -f '+rv.folder; + let txt = 'Regtest: '+rv.folder; if (rv.step) { txt += ' -s '+rv.step; }