본문 바로가기

소프트웨어/NodeJS

NodeJS] Express 설치 및 get을 사용한 간단한 웹서버



1. Express 설치

Express는 NodeJS를 위한 웹 프레임워크이다.

Express API Ref http://expressjs.com/4x/api.html

Express의 설치는 Webstorm Terminal(Alt+f12)를 연 후  npm install express 를 하면 된다.


2. Express로 http server 생성


/**
 * Created by KIMMANSUNG-NOTE on 2014-11-22.
 */

var express = require('express');
var http = require('http');
var app = express();
var server = http.createServer(app);

app.get('/', function(req, res) {
   res.send('hello');
});

app.get('/express.html', function(req, res) {
   res.send('hello express');
});

app.listen(8001, function() {
   console.log('Express erver listen');
});






'소프트웨어 > NodeJS' 카테고리의 다른 글

NodeJS] 간단한 Http Server  (0) 2014.11.22
NodeJS] NodeJS 설치 및 Webstrom에서 Project 생성  (0) 2014.11.22