-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: update synopsis, toc, other nits #6167
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,43 @@ | ||
# Synopsis | ||
# Usage | ||
|
||
<!--type=misc--> | ||
|
||
`node [options] [v8 options] [script.js | -e "script"] [arguments]` | ||
|
||
Please see the [Command Line Options][] document for information about | ||
different options and ways to run scripts with Node. | ||
|
||
## Example | ||
|
||
An example of a [web server][] written with Node.js which responds with | ||
`'Hello World'`: | ||
|
||
```js | ||
const http = require('http'); | ||
|
||
http.createServer( (request, response) => { | ||
response.writeHead(200, {'Content-Type': 'text/plain'}); | ||
response.end('Hello World\n'); | ||
}).listen(8124); | ||
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'); | ||
}); | ||
|
||
console.log('Server running at http://127.0.0.1:8124/'); | ||
server.listen(port, hostname, () => { | ||
console.log(`Server running at http://${hostname}:${port}/`); | ||
}); | ||
``` | ||
|
||
To run the server, put the code into a file called `example.js` and execute | ||
it with the node program | ||
it with Node.js: | ||
|
||
``` | ||
$ node example.js | ||
Server running at http://127.0.0.1:8124/ | ||
Server running at http://127.0.0.1:3000/ | ||
``` | ||
|
||
All of the examples in the documentation can be run similarly. | ||
|
||
[Command Line Options]: cli.html#cli_command_line_options | ||
[web server]: http.html |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
<div id="column2" class="interior"> | ||
<div id="intro" class="interior"> | ||
<a href="/" title="Go back to the home page"> | ||
Node.js (1) | ||
Node.js | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be more appropriate to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nm. wasn't paying attention to what file this was located in. our man page should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our man page is |
||
</a> | ||
</div> | ||
__GTOC__ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: calc is discouraged for portability and preformance, no? If copy paste then defer this for some later time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calc()
has been supported across the board for a good while: http://caniuse.com/#feat=calcThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was something about it resulting in more and multiple passes during reflow, but I think that is outdated. Scratch the above then. Thx