This coding challenge is an exercise to look at your programming style. This is your chance to show off your programming design skills, your testing habits (unittest), and your attention to details. Your solution should be well documented and tested for production release. It should follow good Python conventions, and should be easy to get running.
- A single zip file named <lastname_jobposition_date.zip>
- python files (you can create as many files as you want, you are allowed to create framework template)
- server.log (log file for capturing all output from server side)
- README.md (write instructions how to run your file)
After you’ve engineered a solution to your satisfaction, package up your response and send it through Email.
Design and implement a RESTful web API that can be used to maintain a database of GUIDs (Globally Unique Identifier) and associated metadata. The API must expose commands to perform CRUD operations (Create, Read, Update, Delete). GUIDs should be 32 hexadecimal characters, all uppercase. The GUIDs should be valid only for a limited period of time, with a default of 30 days from the time of creation, if an expiration time is not provided. The expiration time should be formatted in Unix Time. Input and output data should be valid JSON format. Validations should be put in place to make sure input data conforms the specified formats. Code must be documented.
Bonus points if the solution is fully asynchronous.
Creates a new GUID and stores it in the database along with the metadata provided. If a GUID is not specified, the system should generate a random one.
Example 1
URL: POST /guid/9094E4C980C74043A4B586B420E69DDF
Input:
{
"expire": "1427736345",
"user": "Salemount Labs"
}
Output:
{
"guid": "9094E4C980C74043A4B586B420E69DDF",
"expire": "1427736345",
"user": "Salemount Labs"
}
---------
Example 2
URL: POST /guid
Input:
{
"user": "Jay Patel"
}
Output:
{
"guid": "9094E4C980C74043A4B586B420E69DDF",
"expire": "1427736345",
"user": "Jay Patel"
}
Returns the metadata associated to the given GUID.
Example
URL: GET /guid/9094E4C980C74043A4B586B420E69DDF
Output:
{
"guid": "9094E4C980C74043A4B586B420E69DDF",
"expire": "1427736345",
"user": "Jay Patel"
}
Updates the metadata associated to the given GUID. The GUID itself cannot be updated using this command.
Example
URL: PATCH /guid/9094E4C980C74043A4B586B420E69DDF
Input:
{
"expire": "1427822745",
}
Output:
{
"guid": "9094E4C980C74043A4B586B420E69DDF",
"expire": "1427822745",
"user": "Jay Patel"
}
Deletes the GUID and its associated data.
Example
URL: DELETE /guid/9094E4C980C74043A4B586B420E69DDF
No output.
The following response codes should be returned by the service:
- 200's on accepted/successful requests
- 400's on client errors
- 500's on server errors
- Use the Django/Flask/Tornado web framework for the RESTful interface
- Use Redis for the cache
- Use MySQL or MongoDB to store data permanently
- The application should use a cache layer to quickly serve the most recently used GUIDs.
Please ensure your program runs correctly for Python 3+ version.
Questions? Feel free to email. Good luck! 👍
Jay Patel([email protected])
To be fancy, how about trying one of "Producer-Consumer" pattern? e.g. celery, Faktory