node.js: How to use express.js

mkdir URL_req
npm init
touch express.js
npm install express -save
var express = require('express');var app = express();app.get('/',function(req, res) {res.send("Technology's Store");});app.get('/laptops',function(req,res){res.send("Laptops Category");});app.get('/smartphones',function(req,res){res.send("Smartphones Category");});app.get('/tablets',function(req,res){res.send("Tablets Category");});app.listen(8088,function(){console.log("Servidor ativo no porto 8088");});
node express.js
http://localhost:8088/
http://localhost:8088/laptops
http://localhost:8088/smartphones
http://localhost:8088/tablets

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Afonso Antunes

Afonso Antunes

Finalist student in Computer Engineering