Difference between revisions of "WebFund 2014W: Assignment 4"

From Soma-notes
Jump to navigation Jump to search
(Created page with "TBA")
 
Line 1: Line 1:
TBA
'''This assignment is not yet finalized'''
 
In this assignment you are to examine, modify, and answer questions regarding the [http://homeostasis.scs.carleton.ca/~soma/webfund-2014w/T9/tinywebserver.js tinywebserver.js] sample node application.  The single file of this application is also listed below.
 
Please submit your answers as a single JavaScript file called "<username>-comp2406-assign4.js" (where username is your MyCarletonOne username), where this file is your modified version of tinywebserver.js.  Make sure to include the text "COMP 2406 Assignment 4", your name, student number, and the date in the comments at the very top of the file.  If you have trouble submitting your program to cuLearn, add a .txt extension to the file.
 
==Questions==
 
There are six questions below with a total of 20 points.  Please answer all questions.
 
# [2] Change the application so that it listens to the port specified by the PORT environment variable if it is defined.  If no PORT environment variable is defined. the server should listen on port 3000.
# [2] Change the server to serve files from $HOME/public_html rather than the current directory, where $HOME is the home directory of the current user.  Thus if you are logged in as the user student, the server should serve files from <tt>/home/student/public_html</tt>.
# [4] Change tinywebserver.js so it returns a simple HTML error page in response to 404 errors (page not found).  Please be creative in your choice of error page.
# [4] Using the [http://jade-lang.com/api/ <tt>jade</tt> module], change the server so that files that end in <tt>.jade</tt> are turned into HTML files before being returned to the client.  Make sure jade files can include other jade files in the same directory (e.g., by using <tt>extends</tt> in the way we have in other programs this semester).
# [4] Using the [http://nodejs.org/api/querystring.html <tt>querystring</tt> module], make it so that arguments passed in the URL are passed on to the jade file.  For example, <tt>http://localhost:3000/index.jade?title=MyApp</tt> should render index.jade with the value of <tt>title</tt> being "MyApp".
# [4] Change the program so that accesses to directories will return the (properly rendered) contents of index.jade if no index.html file exists.

Revision as of 16:15, 23 March 2014

This assignment is not yet finalized

In this assignment you are to examine, modify, and answer questions regarding the tinywebserver.js sample node application. The single file of this application is also listed below.

Please submit your answers as a single JavaScript file called "<username>-comp2406-assign4.js" (where username is your MyCarletonOne username), where this file is your modified version of tinywebserver.js. Make sure to include the text "COMP 2406 Assignment 4", your name, student number, and the date in the comments at the very top of the file. If you have trouble submitting your program to cuLearn, add a .txt extension to the file.

Questions

There are six questions below with a total of 20 points. Please answer all questions.

  1. [2] Change the application so that it listens to the port specified by the PORT environment variable if it is defined. If no PORT environment variable is defined. the server should listen on port 3000.
  2. [2] Change the server to serve files from $HOME/public_html rather than the current directory, where $HOME is the home directory of the current user. Thus if you are logged in as the user student, the server should serve files from /home/student/public_html.
  3. [4] Change tinywebserver.js so it returns a simple HTML error page in response to 404 errors (page not found). Please be creative in your choice of error page.
  4. [4] Using the jade module, change the server so that files that end in .jade are turned into HTML files before being returned to the client. Make sure jade files can include other jade files in the same directory (e.g., by using extends in the way we have in other programs this semester).
  5. [4] Using the querystring module, make it so that arguments passed in the URL are passed on to the jade file. For example, http://localhost:3000/index.jade?title=MyApp should render index.jade with the value of title being "MyApp".
  6. [4] Change the program so that accesses to directories will return the (properly rendered) contents of index.jade if no index.html file exists.