- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Shyam Hande has Published 72 Articles
Shyam Hande
2K+ Views
Lets first start with writing a simple HTML code and see how we can use ReactBasic React example − Create a simple div like below − Steve My hobby: Cricket Add some styling elements.player{ border:1px solid #eee; width:200px; box-shadow:0 2px 2px #ccc; padding: 22px; ... Read More
Shyam Hande
6K+ Views
In html files we can simply add style in head section − //add css code We can add inline css styles as well in html directly.Generally css is separated from the html ... Read More
Shyam Hande
2K+ Views
So far we sent html code directly from the send(0 function in response object. For sending larger code, we definitely require to have a separate file for html code.sendFile() function−Response object gives a sendFile() function to return a html file to client.How to provide path to html file in sendFile() ... Read More
Shyam Hande
297 Views
We added express router to handle routes. One single router file handles multiple routes.Adding a path for router in App.js −const http = require('http'); const express = require('express'); const bodyParser = require('body-parser'); const route = require('./routes'); const app = express(); app.use(bodyParser.urlencoded({extended: false})); app.use('/test', route); app.use((req, res, next)=>{ res.status(404).send(' Page not ... Read More
Shyam Hande
812 Views
Now we have a App.js and route.js for handling routes. For any other http requests for which we have not added any request handling will results into an error page. Example for url ‘test’ −App.jsconst http = require('http'); const express = require('express'); const bodyParser = require('body-parser'); const route = ... Read More
Shyam Hande
2K+ Views
In earlier examples, we wrote all routing code in a single file App.js. But in real world scenarios, we have to split the code into multiple files.We can create separate files and import them but express gives a router mechanism which is easy to use.Create a separate file called route.js ... Read More
Shyam Hande
1K+ Views
We used use() function to execute middleware’s . Example we used below will be executed for both http GET and POST method −const http = require('http'); const express = require('express'); const bodyParser = require('body-parser'); const app = express(); app.use(bodyParser.urlencoded({extended: false})); app.use('/', (req, res, next)=>{ next(); }); app.use('/add-username', (req, res, ... Read More
Shyam Hande
703 Views
To receive some data in http request , lets add a form on url path ‘/add-username’:app.use('/add-username', (req, res, next)=>{ res.send(' Send '); });For parsing the http request, we requires a third party library body-parser: It’s a production required dependencynpm install –save body-parserexpress js provides middleware use ... Read More
Shyam Hande
251 Views
For handling different routes, use() function is used. use() function has multiple overloaded version, one of version also takes url path as a argument. Based on the url path, the requests will be filtered out for respective middleware.const http = require('http'); const express = require('express'); const app = express(); app.use('/', ... Read More
Shyam Hande
271 Views
Each request in app goes through multiple middleware’s in express. If one of the middleware returns the response it ends there. If any middleware wants to pass the request to next middleware, it uses next() function call at the end of its function call.Http Request -> Middleware (req, resp, next)-> ... Read More