Skip to content

Commit

Permalink
Merge pull request #163 from sympy/status-endpoint
Browse files Browse the repository at this point in the history
Add status endpoint to check if app is running
  • Loading branch information
aktech authored May 5, 2020
2 parents 7169fe6 + 6f6a48c commit 76f4192
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ deploy:
after_deploy:
- pip install requests
- python bin/update_status_on_pr.py
- status_code=$(curl --write-out %{http_code} --silent --output /dev/null https://$TRAVIS_BRANCH-dot-sympy-live-hrd.appspot.com/status)
- echo "App status code => $status_code"
- if [ "$status_code" != "200" ]; then travis_terminate; fi

env:
global:
Expand Down
11 changes: 11 additions & 0 deletions app/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,12 +829,22 @@ def get(self):

self.response.out.write("Your queries have been deleted.")


class RedirectHandler(webapp.RedirectHandler):
"""Redirects deprecated pages to the frontpage."""

def get(self):
self.redirect('/', permanent=True)


class StatusHandler(webapp.RequestHandler):
"""Status endpoint to check if the app is running or not."""

def get(self):
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(json.dumps({"status": "ok"}))


application = webapp.WSGIApplication([
('/', FrontPageHandler),
('/evaluate', EvaluateHandler),
Expand All @@ -845,4 +855,5 @@ def get(self):
('/shellmobile', RedirectHandler),
('/shelldsi', RedirectHandler),
('/helpdsi', RedirectHandler),
('/status', StatusHandler),
], debug=_DEBUG)

0 comments on commit 76f4192

Please sign in to comment.