
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

2K+ Views
Now we have an App.js file shown below, we want to redirect the user back to ‘/’ once user name is received by node server. We will store user name in a file named username.txtInitial App.js file −const http = require('http'); const server = http.createServer((req, res)=>{ const url = req.url; if(url === '/'){ res.write(''); res.write(' Hello TutorialsPoint '); res.write(' Submit '); res.write(''); return res.end(); } res.write(''); res.write(' Hello TutorialsPoint '); ... Read More

1K+ Views
Routing http requests is important because we want to execute different business rules based on request url and the responses will be different for each routes.Earlier we saw, we can get the url by request.url in node. Simple example of user name input with routes is shown below −const http = require('http'); const server = http.createServer((req, res)=>{ const url = req.url; if(url === '/'){ res.write(''); res.write(' Hello TutorialsPoint '); res.write(' Submit '); res.write(''); ... Read More

1K+ Views
App.js −const http = require('http'); const server = http.createServer((req, res)=>{ console.log(req.url, req.method, req. headers); }); server.listen(3000);As shown in above example code, we have request and response parameter object as an argument in createServer method.Response (res) object will be used to send back data to client. It has many properties, some are explained below −res.setHeader(‘Content-Type’, ‘text/html’); this line will set the format of response content o text/html.How to send html content from node.jswrite() function method on response object can be used to send multiple lines of html code like below.res.write(‘’); res.write(‘ Hello TutorialsPoint ’); res.write(‘ Hello Tutorials ... Read More

357 Views
App.jsconst http = require('http'); const server = http.createServer((req, res)=>{ console.log(req); }); server.listen(3000);Run it with command: node App.jsWe can see what is inside a request object by opening a browser and navigating to localhost:3000There is lots of information which will get printed on console window. We will see some important properties.Identifying the url from where request came, request method type and headers in request is important.Headers will give us information on host and browser type , accepted response by host etc. Request method can be of any http method type like GET, POST, PUT, DELETE etc.const http = require('http'); const ... Read More

2K+ Views
Simple http server in node.js will register an event loop which will keep on listening for http requests.Execution of file containing code for creation of server will work as shown below −node App.js => Start executing script => Code parsing, Register events and functions => event loop=> keeps on running as long as event are registered.This is the single threaded event driven approach of the node.js. For accessing and updating of values in database also works using the event driven approach. Even though it’s a single threaded, it can handle multiple requests at a time due to its speed of ... Read More

550 Views
The mostly used core modules of Node.js are −http − used to launch a simple server, send requestshttps − used to launch a ssl secured http serverpath − used to handle path based on operating systemfs − It’s a file system handling moduleos − its used for os related operationsLets build a simple http server using Node.js −Create a javascript file App.js (name it as you like) in an editor like visual studio code .App.jsconst http = require(‘http’); function reqListener(req, res){ console.log(‘Hello’); } const server = http.createServer(reqListener); server.listen(3000);ExplainationWe used const keyword instead of var or let to import a ... Read More

796 Views
Suppose there is a special square room with mirrors on each of the four walls. In each corner except the southwest corner, there are receptors. These are numbered as 0, 1, and 2. Now the square room has walls of length p, and a laser ray from the southwest corner first meets the east wall at a distance q from the 0th receptor. We have to find the number of the receptor that the ray meets first.So if p = 2, and q = 1, then the case will be like −So the output will be 2, as the ray ... Read More

385 Views
Suppose we have a balanced parentheses string S, we have to compute the score of the string based on the following rule −The () has score 1AB has score A + B, where A and B are two balanced parentheses strings.(A) has score 2 * A, where A is a balanced parentheses string.So if the input is like “(()(()))”, then the output will be 6.To solve this, we will follow these steps −ans := 0, define a stack stfor i in range 0 to size of string Sif S[i] is opening parentheses, then insert -1 into stackotherwiseif top of stack ... Read More

537 Views
Suppose there are N cars that are going to the same destination along a one lane road. The destination is ‘target’ miles away. Now each car i has a constant speed value speed[i] (in miles per hour), and initial position is position[i] miles towards the target along the road.A car can never pass another car ahead of it, but it can catch up to it, and drive bumper to bumper at the same speed. Here the distance between these two cars is ignored - they are assumed to have the same position. A car fleet is some non-empty set of ... Read More

3K+ Views
Suppose we have a string S of lowercase letters, and an integer array shifts. The shift of a letter means the next letter in the alphabet, for z, it will be a. Now for each shifts[i] = x, we want to shift the first i+1 letters of S, x times. We have to find the final string after all such shifts to S are applied. So if the string is “abc” and shifts = [3, 5, 9], then after shifting the first 1 letter of S by 3, will have “dbc”, shifting first two letters of S by 5, we ... Read More