Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add health check endpoint #329

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ 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('{}', response.get_data(as_text=True).strip())
yurushao marked this conversation as resolved.
Show resolved Hide resolved

def test_preview_password(self):
password = "I like novelty kitten statues!"
key = snappass.set_password(password, 30)
Expand Down
Loading