on master help sign in
healthcheck endpoint
commit54a2cd040e8411afeabf4feefa29f51d77b19469 authorIgor Rzegocki <igor@rzegocki.pl> dateSat 2 Oct 2021, 17:00 (5 years ago) parent53c4031
2 files changed+10
searx/webapp.py+5 tests/unit/test_webapp.py+5
searx/webapp.py+5
@@ -584,6 +584,11 @@ def index():
584584 )
585585
586586
587+@app.route('/healthz', methods=['GET'])
588+def health():
589+ return Response('OK', mimetype='text/plain')
590+
591+
587592@app.route('/search', methods=['GET', 'POST'])
588593def search():
589594 """Search query in q and return results.
tests/unit/test_webapp.py+5
@@ -188,6 +188,11 @@ class ViewsTestCase(SearxTestCase):
188188 self.assertEqual(result.status_code, 200)
189189 self.assertIn(b'<h1>About <a href="/">searx</a></h1>', result.data)
190190
191+ def test_health(self):
192+ result = self.app.get('/healthz')
193+ self.assertEqual(result.status_code, 200)
194+ self.assertIn(b'OK', result.data)
195+
191196 def test_preferences(self):
192197 result = self.app.get('/preferences')
193198 self.assertEqual(result.status_code, 200)