From 13c355c4c45d79f84666c8306463969db804f83c Mon Sep 17 00:00:00 2001 From: Igor Rzegocki Date: Sat, 2 Oct 2021 17:00:37 +0200 Subject: [PATCH] healthcheck endpoint --- searx/webapp.py | 5 +++++ tests/unit/test_webapp.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/searx/webapp.py b/searx/webapp.py index ee558a5f..98480e4b 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -618,6 +618,11 @@ def index(): ) +@app.route('/healthz', methods=['GET']) +def health(): + return Response('OK', mimetype='text/plain') + + @app.route('/search', methods=['GET', 'POST']) def search(): """Search query in q and return results. diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py index ff58aa1e..cfaa4fb9 100644 --- a/tests/unit/test_webapp.py +++ b/tests/unit/test_webapp.py @@ -191,6 +191,11 @@ class ViewsTestCase(SearxTestCase): self.assertEqual(result.status_code, 200) self.assertIn(b'

About searxng

', result.data) + def test_health(self): + result = self.app.get('/healthz') + self.assertEqual(result.status_code, 200) + self.assertIn(b'OK', result.data) + def test_preferences(self): result = self.app.get('/preferences') self.assertEqual(result.status_code, 200)