Skip to content

Commit

Permalink
Add health check endpoint (#329)
Browse files Browse the repository at this point in the history
* Add health check endpoint

* Add assertion on  status
  • Loading branch information
yurushao authored Feb 3, 2024
1 parent 74ded41 commit 455db36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions snappass/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ def show_password(password_key):
return render_template('password.html', password=password)


@app.route('/_/_/health', methods=['GET'])
@check_redis_alive
def health_check():
return {}


@check_redis_alive
def main():
app.run(host='0.0.0.0')
Expand Down
5 changes: 5 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def setUp(self):
snappass.app.config['TESTING'] = True
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):
password = "I like novelty kitten statues!"
key = snappass.set_password(password, 30)
Expand Down

0 comments on commit 455db36

Please sign in to comment.