9th December 2013 - A Gentle Introduction to Web Apps...
Create a web application to calculate the cooking time for a Christmas turkey.
-
Your application should take the weight in kg from the path given to the web application, and return the cooking time in plain text. e.g. visiting http://localhost:8000/5.25 in your browser should return:
X hours YY minutes
-
Use the following to calculate cooking time - these are base on NHS guidelines for turkey cooking time but having fixed the "gotchas" contained therein (if you finish early, see how many you can find there!):
- allow 45 minutes per kg plus 20 minutes for a turkey under 4.5kg
- allow 40 minutes per kg plus 20 minutes for a turkey of 4.5kg or more but less than 6.5kg
- allow 35 minutes per kg plus 20 minutes for a turkey of 6.5kg or more
-
Your application should comply with PEP 333 - WSGI, pronounced "whisky"
-
Use ONLY The Python standard library - DO NOT use a Python web-framework to achieve the task
(doing the task without a framework will give you a better understanding of how some of the frameworks operate if you need to use them in future)
- The built-in
wsgiref
module is your friend!
You're surely not expecting me to give you that just yet! I'll try to make available by about 19:30.
-
Have the application return the result in HTML or JSON
-
Fix the default calculation so that the application doesn't return odd result (shorter cooking times for a larger turkeys) around the thresholds (4.5kg, 6.5kg).
-
Write a web app that performs a task from a previous PyPool:
- Love calculator
- Roman numeral conversion - Roman to Arabic or Arabic to Roman
-
Run your WSGI app under another framwework's web server (e.g. CherryPy, Tornado) - these are probably more suitable for production use than the server provided by
wsgiref
!