ECS 189H Assignment 4
Server for both static and dynamic queries
Please submit by 12 midnight, Thursday May 11, using Canvas.
In this first assignment we'll start setting up the server to handle
our photo sorting
application, and get the interaction between the server and the browser going.
- Start off by logging into your server account on
138.68.35.50, our server, using your Kerberos login, get your
port number, and add it to the server
from Monday's lecture, server2.js.
Try it out!
- Now check out the documentation for the npm module node-static, which can be used to add
a static server.
- Make a sub-directory off of your home directory called public, and put
your Weather App program there.
-
Now copy server2 to server3, and edit server3 so that if there is no query,
it tries to serve a static file from the public directory. Use the
node-static module. Check to see that you can load your Weather App.
Just to be clear, your server should be able to
serve any static html, css, js, or other files from /public or any of
it's subdirectories, not just your Weather app. Any directory structure
for your Weather app such that it works is fine.
- If you want (not required, but will be for next iteration so why
not do it now), you can have your server respond with a "404 not found"
page if it gets a request for a static file that is not in the
/public directory. There is some documentation on how to do this
on npm, in the
section on "serving specific files". Notice that the static file
server object changes its name from "file" to "fileServer" (grrr).
Hand in your version of server3.js using Canvas.
You do not have to hand in your Weather app again, or
any other files!.