Add health check endpoint (#329)

* Add health check endpoint

* Add assertion on  status
This commit is contained in:
Yuru Shao 2024-02-02 16:14:51 -08:00 committed by GitHub
parent 74ded4156b
commit 455db36189
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View file

@ -202,6 +202,12 @@ def show_password(password_key):
return render_template('password.html', password=password) return render_template('password.html', password=password)
@app.route('/_/_/health', methods=['GET'])
@check_redis_alive
def health_check():
return {}
@check_redis_alive @check_redis_alive
def main(): def main():
app.run(host='0.0.0.0') app.run(host='0.0.0.0')

View file

@ -106,6 +106,11 @@ class SnapPassRoutesTestCase(TestCase):
snappass.app.config['TESTING'] = True snappass.app.config['TESTING'] = True
self.app = snappass.app.test_client() self.app = snappass.app.test_client()
def test_health_check(self):
response = self.app.get('/_/_/health')
self.assertEqual('200 OK', response.status)
self.assertEqual('{}', response.get_data(as_text=True).strip())
def test_preview_password(self): def test_preview_password(self):
password = "I like novelty kitten statues!" password = "I like novelty kitten statues!"
key = snappass.set_password(password, 30) key = snappass.set_password(password, 30)