COMP 519: Web Programming
Autumn 2015

Assignment 3: CGI and Python


2 December 2015 (5pm)


The third assignment is about CGI programming using Python. This involves capturing user input, and processing that input in an appropriate fashion. Thus, an understanding how information is transmitted via a web browser is important, along with how that information can be accessed and used to return a new webpage to the user, based on that input.

Learning outcomes

The purpose of this assignment is for you to demonstrate the following learning outcomes and for me to assess your achievement of them.

Students should:

  1. have an understanding of the range of programming techniques and languages available to organisations and businesses and be able to choose an appropriate architecture for a web application.
  2. be able to demonstrate abilities to design and implement maintainable web sites.
  3. be able to make informed and critical desicisions regarding client development using HTML and JavaScript.
  4. be able to design and implement reasonably sophisticated server-side applications using one or more suitable technologies.
  5. have the knowledge to critically analyse and evaluate web applications.
  6. have a critical and systematic understanding of web protocols.

Description of the task

Important Note

While it's entirely possible to write (at least some of) the functionality of these problems in, say, JavaScript, the intention of this exercise is to show me that you can program (at least at a beginner's level) in Python, and combine that knowledge with the CGI technology that we have discussed in class. So, for example, while you could write a (purely) JavaScript function that could test whether a string is a palindrome and implement this on an appropriate web page, doing so won't earn you any sort of credit for this assignment.

Use Python (called from a web page that you design, and Python code that you write) to do this job!

Part 1 (35+15 points)

Write a webpage called palindrome.html which will test strings (which may or may not include numbers) to see if they are palindromes. The user can input a string, and then a script will check to see if the string is a palindrome or not, displaying the result to the user on another page (include the original string that they input in the displayed output). You should disregard the case of letters, as well as spaces and any punctuation symbols in the sentence (use Python string routines to deal with these issues) when you check to see if it is a palindrome.

For example, the string "Madam, I'm Adam" is a palindrome (disregarding upper/lower case, spaces, and punctuation symbols), and the number 15751 is a palindrome too. The strings "Ma'am, I'm Adam" and "34546" aren't.

For an extra 1-15 points, allow the user to input up to five strings at once and display results for all of them on the same page. If the user only inputs one or two strings to test, then you should only output information about those strings (i.e. don't assume that they will enter exactly five strings).

Part 2 (35+15 points)

Write a web page called rateme.html which allows visitors to rate your home page. That is, create a small web page with radio buttons with which the visitor can rate your home page as very good, good, so-so, bad, or very bad. The overall results of the survey should be stored on the web server. After pressing the submit button, the overall survey results should be shown to the visitor.

For extra 1-15 points, your system should survey ratings by distinct visitors only, and also allow someone to change their rating.


Since you're going to be using Python and CGI server for these tasks, you need to place your files in the proper directory as mentioned in class so that these scripts will execute properly. Include links to your pages on your home page as well.

Submission of work

Having your webpages online is a necessary part of this assignment so that I can accurately check they are working correctly (i.e. gathering input from a user who utilizing a browser).

As for the last assignments, you must submit your webpages via the Department's Coursework Submission System. That's the "official proof" that your assignment has been submitted on time. Please include whatever files (e.g. HTML, external CSS files, Python scripts) are appropriate in your submission. You can create one zipped file for your submission. Please do not use the RAR (or some other proprietary) format!

Please remember to have your webpages online so that I can access them via a web browser and to submit them to the Coursework Submission System by 5pm on the day they are due.

When submitting your solution, don't forget to include a completed Declaration of Academic Integrity.


This assignment contributes 1/4 of the 75% continuous assessment part of the course grade. The maximum possible grade on this assignment is 100 points.

Failure in this task can be compensated by higher marks on the other assessments of the module.

Important note:    It is assumed as part of this assignment that the HTML code you write will satisfy the HTML5 standards!! (Include an appropriate Document Type Declaration and consider using the W3C online validator.) Failure to satisfy the HTML5 standards can result in losing marks from your grade.

COMP519 marking descriptors

GradeClassificationPercentage Qualitative Description
A*Good Distinction80+Factually almost faultless; perceptive and focused treatment of all issues. Clearly directed; logical; comprehensive coverage of topic; strong evidence of reading/research outside the material presented in the programme; substantial elements of originality and independent thought; very well written. critical and scholarly presentation.
ADistinction70-79Logical; enlightening; originality of thought or approach; good coverage of topic; clear, in-depth understanding of material; good focus; good evidence of outside reading/research; very well written and directed.
BGood Pass60-69Logical; thorough; factually sound (no serious errors); good understanding of material; evidence of outside reading/research; exercise of critical judgement; some originality of thought or approach; well written and directed.
CPass50-59Worthy effort, but undistinguished outcome. Essentially correct, but possibly missing important points or inadequate treatment. Largely derived from material delivered in the programme, but with some evidence of outside reading/research; some evidence of critical judgement; some weaknesses in expression/presentation.
DCompensatable Fail40-49Incomplete coverage of topic; evidence of poor understanding of material; Poor presentation; lack of coherent argument. Very basic approach to a narrow or misguided selection of material. Lacking in background and/or flawed in structure.
FFail< 40Serious omissions; significant errors/misconceptions; poorly directed at targets; evidence of inadequate effort. Shallow and poorly presented work showing failure in understanding.

Late submissions

The University's standard policy on lateness penalties will be applied with respect to the latest electronic submission of the assessment. See Section 6 of the Code of Practice on Assessment for further details.