close

First download Nodejs fom 

https://nodejs.org/en/download/

Create forder where you want to build a project 

Create the file "Server name".js and

 

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello Myfriend\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

final run server, open cmd : node "server name".js

it will run at 127.0.0.1:3000

finish.

 

 

arrow
arrow
    文章標籤
    nodejs
    全站熱搜

    duanana 發表在 痞客邦 留言(0) 人氣()