From f69d2801069850b48c6424b50d0107799d56e2f8 Mon Sep 17 00:00:00 2001 From: Guillaume Pasquet Date: Sun, 20 Feb 2022 09:30:46 +0000 Subject: Handle errors (more) gracefully --- test_api/test_api.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test_api/test_api.py (limited to 'test_api/test_api.py') diff --git a/test_api/test_api.py b/test_api/test_api.py new file mode 100644 index 0000000..bd8303d --- /dev/null +++ b/test_api/test_api.py @@ -0,0 +1,19 @@ +from bottle import get, post, run, HTTPError + +@get("/") +def get_root(): + return {"status": "OK"} + +@post("/") +def post_root(): + return {"status": "SUCCESS"} + +@get("/errors/404") +def error_404(): + raise HTTPError(404, body={"error": "no exist"}) + +@get("/errors/500") +def error_500(): + raise HTTPError(500, body={"error": "server error"}) + +run(host="localhost", port=8080) -- cgit v1.2.3