diff options
Diffstat (limited to 'test_api/test_api.py')
-rw-r--r-- | test_api/test_api.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test_api/test_api.py b/test_api/test_api.py index cce55f4..02eb491 100644 --- a/test_api/test_api.py +++ b/test_api/test_api.py @@ -1,4 +1,4 @@ -from bottle import get, post, run, HTTPError +from bottle import get, post, run, HTTPError, request @get("/") def get_root(): @@ -24,4 +24,16 @@ def error_404(): def error_500(): raise HTTPError(500, body={"error": "server error"}) +@post("/auth") +def post_auth(): + return {"token": "blah1234"} + +@get("/profile") +def get_profile(): + if request.headers.get("TOKEN") != "blah1234": + raise HTTPError(401, body={"error": "Not Authorized"}) + return { + "user": "John Doe" + } + run(host="localhost", port=8080) |