o9s
is a microblog
home archives search feed blogroll


Expressly Set Up An Express Server

mkdir my_express_project
cd !$
npm init
npm install express -S
vim index.js

Copy this in index.js.

const express = require('express');

const app = express();

// You can also use app.get, app.put, app.delete, etc.
app.post('/', (res, req) => {
  console.log(res);
  console.log(req);
});

app.listen(3000, () => console.log('=> Ctrl-C to shutdown server'));

You can run your server with the following command.

node index.js

Test your server with Postman by doing a POST request to localhost:3000/. You will see activity in your terminal.

Posted on 2018-02-07   #node     #javascript  






← Next post    ยท    Previous post →