From 54a2cd040e8411afeabf4feefa29f51d77b19469 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 7edf21f8..f32fa2fc 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -584,6 +584,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 e8819fdc..155938ce 100644 --- a/tests/unit/test_webapp.py +++ b/tests/unit/test_webapp.py @@ -188,6 +188,11 @@ class ViewsTestCase(SearxTestCase): self.assertEqual(result.status_code, 200) self.assertIn(b'

About searx

', 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)