Duration: 65 min High School Grades: 9 - 12 CCSS, NGSS
Advanced Web Programming
(3161611)
Duration: 65 min High School Grades: 9 - 12 CCSS, NGSS
Content : 1.) Web Modules
2.) Debugging
Team Members:
Name Enrollment No.
Hardik pampaniya 200130116012
Ghanshyam Ajagiya 200130116018
Mentor : M.N. patel
Web Module
• The Web Module is mainly controlled by web server that handles the request and provide
the responses
What is web server?
• Web server is special type of server to which the web browser submits the request of web
page which is desired by the client.
• There are some popular used web servers such as Apache and IIS from Microsoft.
• Function of web server
Standards
1. The web server accepts the request from the web browser.
2. The user request is processed by the web server
3. The web server respond to the users by providing the services which they demand for
over the web browsers.
4. The web servers serve the web based application.
5. The DNS translate the domain names into the IP addresses.
6. Some servers actively participate in session handling techniques.
• Working Principle of Web Server
• When user submit the request for web page, he/she is actually demanding for page
present in web server.
• When Web browser submits the request for web page, the web server responds this
request by sending back the request page to the web browser of the clients machine.
• Step 1: Web client request for desire web page by providing the IP address of the website.
• Step 2: The web server located the desired web pages on the website and responds by
sending back the request page. if the page doesn’t exsist, it will send back the
appropriate error page.
• Step 3: The web browser receives the page and renders it as required.
• Example code:
• Node.js has a built in module named http which allows us to transfer data over the Hyper
Text Transfer protocol(HTTP
• Now open suitable web browser and type localhost:8082 as URL
Debugging
• Node.js provides a built in debugging tools.
• This tool is command driven and non-graphical tool.
Following table shows various commands used in debugging
Commands Description
next(n) It moves on next line for debugging.
cont(c) Continues the execution and stops at debugger statement if any.
Standards
step Steps in the function.
out Steps out of the function.
watch Add the expression or a variable for inspecting its value.
watchers This allows us to see the value of the expression or variable that are
passed to watch command.
exit It exits the debugging mode and returns to the command prompt.
How to debug a sample Node.js program with the help of following example -
Purposely made this
spelling mistake(length), to
know about this error
during debugging process.
Output
3. Heat from beneath
Note that the length of the contents is undefined because of the wrong spelling. But this program
does not raise any syntactical error. It simply returns ‘undefined’.
So what went wrong? Yes, in order to find it out we need to debug our code.
To debug the above program, run the following command
Promt:\>node debug index.js
By above command, the debugger starts and waits at some line after executing few lines -
As from above screen short, we can notice > symbol which indicates the current debugging statement.
Now wetectonics
4. Plate can use next(n) to move on the next statement
wePlate
4. can tectonics
inspect the values of the variable using watch and watchers command.
And here we get to know, that something went wrong in finding the string length.
And thus the spelling mistake of length attribute of str variable can be corrected.
Then save your node.js file with the appropriate corrections, stop the debugger and re-run the
above program.
Output