Node.js
hello world!
blackbearwow
2022. 7. 15. 17:05
https://nodejs.org/dist/latest-v16.x/docs/api/synopsis.html
Usage and example | Node.js v16.16.0 Documentation
Usage and example# Usage# node [options] [V8 options] [script.js | -e "script" | - ] [arguments] Please see the Command-line options document for more information. Example# An example of a web server written with Node.js which responds with 'Hello, World!'
nodejs.org
위 사이트를 따라하면 hello world!를 출력할 수 있다.
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}/`);
});