2017-05-19 Friday Assignment!

posted May 18, 2017, 6:45 AM by Samuel Konstantinovich   [ updated May 18, 2017, 6:55 AM ]
Check out the cgi/form demo here:

There is also a python file, and the text file with the source of the py file. 

Your goals:
1. Read through the lab, and the source file, to understand how things work.
2. Fix your lab 05 and 06
  /06/form.html   + the py file you linked it to.
3. Complete the lab (also posted on the html file linked above)


Use your newfound skills to write a madlibs form/program. You will take a paragraph or two from a book you like, and allow the user to submit words to see the results. This will ultimately be due at a later date, but starting now and asking about the problems will make it easier, especially when I add a few more parts to the HW next week.

  1. Make a new directory ~/public_html/07madlibs ( place all of the files for this lab in that directory )
  2. Take a short story (posted on the course site) save it as a text file story.txt
  3. Replace 5-10 words with easy to replace strings like $word1$ or *noun1* etc.
  4. Now make a form madlibs.py, that allows the user to submit 5-10 text boxes
  5. Label the box with the type of word you are replacing. like: noun, verb( an example of tense would be helpful), adverb, adjective, etc.
  6. Add a submit button!
  7. Write the program that responds to this form, by reading the story file, and replacing the appropriate words.
  8. Make sure the program prints the new story!

Some story excerpts:

Call me Ishmael. Some years ago- never mind how long precisely- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's hats off- then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball.


'Twas brillig, and the slithy toves
Did gyre and gimble in the wabe: 
All mimsy were the borogoves, 
And the mome raths outgrabe.

"Beware the Jabberwock, my son! 
The jaws that bite, the claws that catch!
Beware the Jubjub bird, and shun 
The frumious Bandersnatch!" 

He took his vorpal sword in hand; 
Long time the manxome foe he sought-
So rested he by the Tumtum tree 
And stood awhile in thought. 


It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way--in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.