Description
Publish a service on the web with two endpoints:
1. /messages takes a message (a string) as a POST and returns the SHA256 hash digest of
that message (in hexadecimal format)
2. /messages/<hash> is a GET request that returns the original message. A request to a
non-existent<hash> should return a 404 error.
Example
Let’s say you publish to http://mywebsite.com/ (you don’t need a custom domain for this
project, any IP address we can access will do):
You can calculate that your result is correct on the command line:
$ echo -n "foo" | shasum -a 256 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae -
You can now query your service for the original message:
$ curl http://mywebsite.com/messages/2c ... fa0f98a5e886266e7ae { "message": "foo" }
$ curl -i http://mywebsite.com/messages/aa ... aaaaaaaaaaaaaaaaaaa HTTP/1.0 404 NOT FOUND Content-Type: application/json Content-Length: 36 Server: Werkzeug/0.11.5 Python/3.5.1 Date: Wed, 31 Aug 2016 14:21:11 GMT { "err_msg": "Message not found" }
(your specifics may vary, all that matters is that you get a 404)