commit b147da2c299ac527d796af8856de2b890302acc2 Author: Steffen Vogel Date: Thu Jun 2 16:33:44 2016 +0200 added Python WSGI app to lint URA JSON requests diff --git a/wsgi/ura_linter.py b/wsgi/ura_linter.py new file mode 100755 index 0000000..95842f6 --- /dev/null +++ b/wsgi/ura_linter.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import json +import requests + +from wsgiref.simple_server import make_server +from cgi import parse_qs, escape + + +def get(environ, start_response): + parameters = parse_qs(environ.get('QUERY_STRING', '')) + + url = 'http://ivu.aseag.de/interfaces/ura/instant_V1' +# url = 'http://countdown.api.tfl.gov.uk/interfaces/ura/instant_V1' + + r = requests.get(url, parameters) + + output = [] + for line in r.text.splitlines(): + print line + output.append(json.loads(line)) + + start_response('200 OK', [('Content-Type', 'application/json')]) + + return json.dumps(output) + +if __name__ == '__main__': + srv = make_server('localhost', 8080, get) + srv.serve_forever() \ No newline at end of file