-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f31591c
commit 88e9f60
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
title: Getting Started Guide | ||
layout: docs.hbs | ||
--- | ||
|
||
# How do I start with Node.js after I installed it? | ||
|
||
Once you have installed Node, let's try building our first web server\ | ||
Create a file named "app.js", and paste the following code: | ||
|
||
```javascript | ||
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}/`); | ||
}); | ||
``` | ||
|
||
After that, run your web server using ``` node app.js ```, visit http://localhost:3000, and you will see a message 'Hello World' |