Update example app.

This commit is contained in:
Tom Wilkie
2015-12-17 13:54:42 +00:00
parent 1ef6006c55
commit 6dc65e2481
3 changed files with 22 additions and 4 deletions
+15 -1
View File
@@ -48,12 +48,26 @@ def ignore_error(f):
logging.error("Error executing function", exc_info=sys.exc_info())
return "Error"
@app.route('/')
# this root is for the tracing demo
@app.route('/hello')
def hello():
qotd_msg = do_qotd()
qotd_msg = do_echo(qotd_msg)
return qotd_msg
# this is for normal demos
@app.route('/')
def root():
counter_future = pool.submit(do_redis)
search_future = pool.submit(do_search)
qotd_future = pool.submit(do_qotd)
echo_future = pool.submit(lambda: do_echo("foo"))
result = 'Hello World! I have been seen %s times.' % ignore_error(counter_future.result)
result += ignore_error(search_future.result)
result += ignore_error(qotd_future.result)
result += ignore_error(echo_future.result)
return result
if __name__ == "__main__":
logging.basicConfig(format='%(asctime)s %(levelname)s %(filename)s:%(lineno)d - %(message)s', level=logging.INFO)
WSGIRequestHandler.protocol_version = "HTTP/1.1"