[javascript] Express 비교

KCH·2022년 3월 3일
0

no Express

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 World!\n');
});

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

use Express


const express = require('express');
const app = express();
const port = 3000;

app.get('/', (req, res) => {
    res.end('Hello World!\n');
});

app.listen(port, () => {
    console.log(`Express Server running at http://localhost:${port}/`);
});
profile
dreaming developer

0개의 댓글