Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #40474
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Node.js |
| Date | 2021-10-14 15:34 +0200 |
| Message-ID | <isqpvhFc4phU1@mid.individual.net> (permalink) |
| References | <5f57e300-fd03-466c-96af-75fd67f72420n@googlegroups.com> <c8cfb8c6-deed-4d1f-846d-257b942c79d9n@googlegroups.com> <c9ae1e2b-73b7-4f49-9588-954c2fd7b2f7n@googlegroups.com> |
Jonas Thörnvall:
[...]
> I am not sure what braindead monkey wrote that intro but....
>
> "Now, run your web server using node app.js. Visit
> http://localhost:3000 and you will see a message saying "Hello
> World". Refer to the Introduction to Node.js for a more comprehensive
> guide to getting started with Node.js."
Why do you say "braindead monkey"?
This is instruction is quite clear:
1) Run the command "node app.js" in your console
2) Open your browser and visit http://localhost:3000
> But i think he left out a couple of steps, like it should be run from
> commandline, i got it running now.
Of course! What else should "run your webserver using [node app.js]" mean?
> Is it something similar to PHP, must the whole code base "vanilla
> javascript" be generated dynamically thru the server? Or can i from
> the clientside script invole functionality from server?
Yes, Node.js runs completely on the server and *not* in the browser.
Furthermore Node.js applications are designed to run continously while
in PHP a script will only run once for the request then exit again (yes,
PHP-FPM will continue running and waiting for the next request from the
webserver but each PHP script will just be executed again for each
incoming HTTP request).
For example: The script app.js from
<https://nodejs.org/en/docs/guides/getting-started-guide/> will run as
long as you don't stop the "node" process.
The following function will handle all incoming requests from a browser:
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
"req" is the request object which contains everything sent by the
browser and "res" is the response object which will generate the
response sent back to the browser.
--
Arno Welzel
https://arnowelzel.de
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Node.js Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-13 19:24 -0700
Re: Node.js Julio Di Egidio <julio@diegidio.name> - 2021-10-14 00:12 -0700
Re: Node.js Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-14 01:27 -0700
Re: Node.js Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-14 11:18 +0100
Re: Node.js Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-14 05:26 -0700
Re: Node.js Arno Welzel <usenet@arnowelzel.de> - 2021-10-14 15:37 +0200
Re: Node.js Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-14 15:02 +0100
Re: Node.js Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-14 07:37 -0700
Re: Node.js Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-14 07:46 -0700
Re: Node.js Arno Welzel <usenet@arnowelzel.de> - 2021-10-14 15:34 +0200
Re: Node.js Julio Di Egidio <julio@diegidio.name> - 2021-10-14 23:59 -0700
Re: Node.js Scott Sauyet <scott.sauyet@gmail.com> - 2021-10-15 18:12 -0700
Re: Node.js Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-15 19:18 -0700
Re: Node.js Jon Ribbens <jon+usenet@unequivocal.eu> - 2021-10-16 15:04 +0000
Re: Node.js Julio Di Egidio <julio@diegidio.name> - 2021-10-19 23:09 -0700
Re: Node.js Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-14 01:43 -0700
Re: Node.js Arno Welzel <usenet@arnowelzel.de> - 2021-10-14 15:41 +0200
Re: Node.js Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-14 07:02 -0700
csiph-web