Question: Create a web server that Accepts and processes request messages submitted from browser, and Generates and sends response messages back to browser for display. Your
Create a web server that
- Accepts and processes request messages submitted from browser, and
- Generates and sends response messages back to browser for display.
Your web server must be able to handle
- URL with hostname and port
- Request message URL: 127.0.0.1:3000
- Response message: SUCCESS!
- URL with hostname, port and path
- Request message URL: 127.0.0.1:3000/alpha
- Response message: SUCCESS! alpha
- URL with hostname, port, path and query string
- Request message URL: 127.0.0.1:3000/bravo?name=charlie
- Response message: SUCCESS! bravo charlie
- Invalid/unexpected URL
- Request message URL: 127.0.0.1:3000/mumbojumbo
- Response message: FAILED! Fix your URL.
Hostname 127.0.0.1 can be replaced by localhost.
Port number 3000 can be replaced by any other port number that is from 1024 (2^11) to 65535 (2^17 1) inclusive.
Tools - Use the following:
- Node.js
- Express.js
- Express.js router endpoint path
- Express.js req.query
- GET request
Checklist
Do the following:
- Create a folder that is dedicated to this lab exercise
- Create a Node.js server file
- Insert necessary endpoints
- Listen to selected port
- Create a package.json file with npm init
- Install necessary npm module(s)
- Test the code locally by
- Executing the Node.js server file
- Enter and submit various URLs in browser
ASSUME ALL MODULES HAS BEEN INSTALLED THROUGH NMP, NEED THE CODE ALONE. THANKS
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
