Skip to content

Commit

Permalink
Adds readiness endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
palnabarun committed May 15, 2019
1 parent d2ccfd5 commit 1c29706
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion examples/webpy-todo/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@

urls = (
"/", "index",
"/healthy", "healthy"
"/healthy", "healthy",
"/ready", "ready"
)

READY = False

app = web.application(urls, globals())
render = web.template.render("templates/")

db_url = os.getenv("DATABASE_URL")
db = web.database(db_url)

READY=True

def get_todos():
return db.select("todo", order="id desc")

Expand All @@ -37,5 +42,14 @@ def GET(self):
except:
web.ctx.status = '500 Internal Server Error'

class ready:
def GET(self):
global READY
if READY:
web.ctx.status = '200 OK'
else:
web.ctx.status = '500 Internal Server Error'


if __name__ == "__main__":
app.run()

0 comments on commit 1c29706

Please sign in to comment.