Second Summer 2009


HTTP. Password protected folders.
Take a look at this program.

Can you state it as a problem? Can you solve it?

Here's the code in Perl:

#!/usr/bin/perl

use CGI;

$q = new CGI;

print $q->header, $q->start_html;

$count = $q->param('count') + $q->param('add') + 0;

print qq{
  <table border cellpadding=2>
    <tr><td colspan=2 align=center> <h1>$count</h1>
    <tr><td width=50% align=center> <a href="?count=$count&add=-1">Down</a> <td> <a href="?count=$count&add=1">Up</a>
  </table>
};

print $q->end_html;
Explain how it works. Implement it in Python.

How about this program? Can you implement it?

In lab we will also discuss HTTP and help you set up a password protected folder, where you can post your homework code.

We will add to these notes in real time, in class.

Here are the pages from the book (one, two) with info on how to set up the protected folder.

To post the source code:

  1. assume you have a script somewhere (e.g., ~/apache/cgi-bin/something)
  2. assume you have the protected folder set up already

  3. go into ~/apache/htdocs/protected and issue
  4. this command: ln -s ../cgi-bin/something abc.txt

  5. at this stage http://silo.cs.indiana.edu:44xxx/cgi-bin/something calls your program,
  6. and http://silo.cs.indiana.edu:44xxx/protected/abc.txt will take it to its source code

  7. every time something changes the abc.txt link reflects the change without your intervention


Updated by Adrian German for A202/A598