Week 3,4

Part 1 CGI Apache
  1. Creat a working directory week3 and download the source files from week3 Tutorial folder. Import all files into Eclipse.
  2. Export CGI files or copy from your working directory to your "xampp/cgi-bin/" directory, copy html file i.e. "cgilogon.html" to "xampp/htdocs/" directory

  3. install dicttoxml and test run "createxml.py"

    • Shift+Right-Click to start command prompt in the directory created
    • type "pip install dicttoxml"
    • type "python createxml.py"
    • open "client.xml" with IE

  4. CGI python
    • start xampp control panel and click the config button

    • Add .py to the "AddHandler cgi-script ..." line in the file "httpd.conf"

    • save file and click the "start" button to start the Apache server

  5. Modify python location in first line of all "cgi*.py" file. Use IE to test all program.

Part 2 Programming exercises. Answers

  1. modify cgiplogon.py to display a link to your personal web page.

    Submit "week3q1.py" after you finished.

  2. Given the program slider.py in tutorial folder, modify the code to add two buttons; one to reset puzzle to its initial position, and one to randomize the puzzle.

  3. Write a Python program to implement a simple billing system for a company. Each line of the input data file for the billing system contains a name, address, transaction type, and amount of transaction separated by a "_". The transaction type is either C (for credit) or D (for debit). The transaction amount is given in dollars and cents. If we assume each person's balance is initially zero, that a credit reduces the balance, and a debit increases the balance, the computer program should produce a report, ordered on name, giving the final balance in dollars and cents in each account. If a balance is exactly zero, then that person's balance should not appear in the report.

    Example input:
    Fred Chan_213 Yuen Long Avenue_D_41.03
    Sue Wong_9102 Kowloon Circle_D_10.00
    Fred Chan_213 Yuen Long Avenue_C_0.01
    Baba Li_2000 E. 21st Street_D_450.00
    Sue Wong_9102 Kowloon Circle_C_5.50
    Jay Law_9103 Problem Area_C_25.00
    Fred Chan_213 Yuen Long Avenue_C_41.02
     
    Example output:
    Name		Address	                Balance
    ----		-------	                ------
    Baba Li         2000 E. 21st Street     450.00
    Jay Law         9103 Problem Area       -25.00
    Sue Wong        9102 Kowloon Circle       4.50