29 September 2019

NodeJS ExpressJS: Hello world example [EX-01]


Javascript Frameworks
ExpressJS, SailsJS, MeteorJS, KoaJS, FeathersJS


https://expressjs.com/
https://expressjs.com/en/starter/hello-world.html

npm init
npm install express --save

Hello world example
app.js
const express = require('express')
const app = express()
const port = 3000

// GET method route
app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Example app listening on port ${port}!`))
Command: node app.js
Url: http://localhost:3000/
Kết quả: Hello World!
Url: http://localhost:3000/users
Kết quả: User list

Related Posts:

  • NodeJS Basic - URL Module URL Module Parsing url - query params node.js const http = require('http'); const url = require('url'); const server = http.createServer((req, res) => { const queryData = url.parse(req.url, true).query; co… Read More
  • NodeJS Basic Socket.io Create Module OOP Buffer File  Http Server Express Server Socket.io … Read More
  • NodeJS Basic - HTTP Module HTTP Module Server port 4000 node.js const http = require('http'); const server = http.createServer((req,res) => { res.write('Hello Http'); res.end(); }); server.listen(4000); console.log('Server start ht… Read More
  • NodeJS ExpressJS: Template engines [EX-02] Using template engines with Express Pug (jade), Mustache, EJS [1] Single page application (SPA)  - Nội dung render trên front end  - Không load lại trang  - Tương tác với data dạng Json API [2] Multiple pag… Read More
  • NodeJS ExpressJS: Hello world example [EX-01] Javascript Frameworks ExpressJS, SailsJS, MeteorJS, KoaJS, FeathersJS https://expressjs.com/ https://expressjs.com/en/starter/hello-world.html npm init npm install express --save Hello world example … Read More

0 nhận xét:

Post a Comment

 

BACK TO TOP

Xuống cuối trang