Search for question
Question

Creating a Node Project Tasks

This task assumes that you have already installed Node.js on your computer.

The goal is to demonstrate the successful running of a Node express web server

that is capable of serving both static and dynamic web pages.

You are required to create your own local directory and run a local Node Express

web server. Follow the instructions below to create your own Node project.

1. Run NPM in your created local directory to install the modules: express and

sqlite3.

2. Check the folder/sub-directory node_modules in your local directory to see if the

above modules are installed.

3. Using the express module create a Node.js application (i.e., index.js) that will

set a local web server. The server listens to the port 3000 and sets the

folder/subdirectory public_html as the default server home directory. Any

HTML files saved in this home directory can be accessed by web browsers via

the local server. When the user accesses http://localhost: 3000 using a web

browser (i.e., by default this would normally access the index.html file found in

the public_html folder), the Node.js application should serve the static

message "Welcome to SIT774! This page was served dynamically from the

express server." is displayed.

4. Create the sub-directory/folder public_html in your local directory.

5. Create a HTML document (e.g., test.html) and save it into the public_html.

6. Run the command node or node index.js in a Command Prompt (Windows)

or Terminal (Mac OS) within your local directory to make the server work.

7. Open a web browser (NOTE: You may need to run this in an Incognito window

if you are using a Chrome browser, given a recent bug crbug.com/1173575)

and visit http://localhost: 3000, the message "Welcome to SIT774! This page

was served dynamically from the express server." should be displayed in the

window like: