diff --git a/stw_potsdam/swp_webspeiseplan_api.py b/stw_potsdam/swp_webspeiseplan_api.py index dd8d11b..0dbfae5 100644 --- a/stw_potsdam/swp_webspeiseplan_api.py +++ b/stw_potsdam/swp_webspeiseplan_api.py @@ -92,14 +92,23 @@ class SWPWebspeiseplanAPI: req = urllib.request.Request(SWPWebspeiseplanAPI.URL_BASE) with urllib.request.urlopen(req) as resp: txt = resp.read().decode("utf-8") - match = re.findall(r"/main.[0-9a-f]+.js", txt)[0] + match = re.findall(r"/main.[0-9a-f]+.js", txt) + + if match: + match = match[0] + else: + # Development build made it to production, which does not produce + # JS chunks with cache-busting filenames + match = "/index.js" + SWPWebspeiseplanAPI.logger.debug( "__parse_token: downloading script %s", match ) req = urllib.request.Request(f"{SWPWebspeiseplanAPI.URL_BASE}{match}") with urllib.request.urlopen(req) as resp: txt = resp.read().decode("utf-8") - proxy_token = re.findall(r"PROXY_TOKEN:\"([0-9a-f]+)\"", txt)[0] + proxy_token =\ + re.findall(r"PROXY_TOKEN:\s*[\"']([0-9a-f]+)[\"']", txt)[0] SWPWebspeiseplanAPI.logger.debug( "__parse_token: PROXY_TOKEN %s", proxy_token ) diff --git a/stw_potsdam/views.py b/stw_potsdam/views.py index 22c75f2..034a842 100644 --- a/stw_potsdam/views.py +++ b/stw_potsdam/views.py @@ -71,3 +71,7 @@ def canteen_index(): @app.route("/health_check") def health_check(): return make_response("OK", 200) + + +if __name__ == '__main__': + app.run()