node start - hello world http server

Write a file t1.js

'use strict';

const express = require('express');

// Constants
const PORT = 8080;

// App
const app = express();
app.get('/', function (req, res) {
  res.send('Hello world\n');
});

app.listen(PORT);
console.log('Running on http://localhost:' + PORT);

 

运行

node t1.js

 

在浏览器输入

http://localhost:8080/

 

posted on 2016-07-09 12:20  cutepig  阅读(299)  评论(0编辑  收藏  举报

导航