Week 13 — Homework assignment
due: Tues, December 8, 8pm
Note that this was not actually assigned as we used this class session for review rather than working through the lesson plan for this week. Consider this an optional / extra credit assignment.
Review the class notes for this week.
[Python] Create a kind of web counter that prompts the user for their name, and tells them how many times they have visited your site.
Refer back to the homework from last week. Create an HTML page with a form that includes only one field, asking for the user's name.
Again create a server.py
file that:
if
the key is not already in the dictionary
(remember that you can use not in
), add the
key with a value of 1
;
in
the database), increase the value by 1
, and
set it back as a the value for that key.
As with last week, return a response. This time, simply tell the user something to the effect of:
Hi Rory. You have visited this page 42 times.
I hope that after mastering these principles, you should be able to refer back to week 11 to adapt this for your final project.