Lecture 53: (LABFORM)

posted May 9, 2013, 6:03 AM by Samuel Konstantinovich   [ updated May 9, 2013, 6:26 AM ]
LABFORM:

DIRECTIONS:
1. After completing the lab you should link both html files in your home.html, don't forget to do this!!!
2. Read the entire part A before coding, answer the questions before you code anything!
3. When part A works, move onto part B, making sure to make NEW COPIES of the file so you will end up with both parts. This is important so you don't break your part A!

Part A:
Make an html file: textconvert.html
It should have a form like this:



When you click the button it should send the text to textconvert.py to be processed. All the site will do is reverse the string:

Before you start coding:
Q1. What is the name=  of the text field in the html file? How can you deduce this?
Q2. What is the value= of the submit button? 

Hint1:
Check if the appropriate key is in the fieldstorage before you use it! 

form = cgi.FieldStorage()
if 'thingIwant' in form:
    value = form['thingIwant'].value
    ....

PART B
Read all of Part B before writing any more code!

Make new versions of the html and py files:

The html page should now have radio buttons to select reverse OR rot13:

Before you start coding:
Q3: Does the name= of the two radio buttons matter? Why/Why not?
Q4: Does the value= of the two radio buttons matter? Why/Why not?

When reverse is checked it should work just like before, but when you check ROT13 instead, it will apply the rot13 function to the string:

Since you already wrote ROT13, this should not take any time. I am testing if you can use a radio button. You should copy/paste the rot13 function that you made before, if you didn't write it, print an error message that explains why you don't have a rot13 function, AND an estimated date of completion when you WILL have rot13.





Comments