From 1c297065d05c52b1cd67071d7b6cebfc9660ddf6 Mon Sep 17 00:00:00 2001 From: Nabarun Pal Date: Wed, 15 May 2019 15:47:03 +0530 Subject: [PATCH] Adds readiness endpoints --- examples/webpy-todo/todo.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/webpy-todo/todo.py b/examples/webpy-todo/todo.py index 9a4db99..d7cfaf1 100644 --- a/examples/webpy-todo/todo.py +++ b/examples/webpy-todo/todo.py @@ -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") @@ -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()