Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #40468 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2021-10-13 19:24 -0700 |
| Last post | 2021-10-14 07:02 -0700 |
| Articles | 18 — 6 participants |
Back to article view | Back to comp.lang.javascript
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
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2021-10-13 19:24 -0700 |
| Subject | Node.js |
| Message-ID | <5f57e300-fd03-466c-96af-75fd67f72420n@googlegroups.com> |
I finally decided "try" learn a little node.js. So i installed according to. https://nodejs.org/en/docs/guides/getting-started-guide/ And simply copied app.js to my intetpub directory. But visiting 127.0.0.1:3000 there is nothing. Must i configure IIS to listen to app.js as start page "index.html" What happens if i invoke app.js as a script src within index.html? Can i mix up the node.js code with my vanilla just import them as script SRC?
[toc] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2021-10-14 00:12 -0700 |
| Message-ID | <c8cfb8c6-deed-4d1f-846d-257b942c79d9n@googlegroups.com> |
| In reply to | #40468 |
On Thursday, 14 October 2021 at 04:24:19 UTC+2, jonas.t...@gmail.com wrote: > I finally decided "try" learn a little node.js. > So i installed according to. > https://nodejs.org/en/docs/guides/getting-started-guide/ > > And simply copied app.js to my intetpub directory. That's not what it says: wherever you put app.js, and assuming you have node in your path, you launch it with "node app.js" from the command line after cd-ing to where the file is (in this case: of course you can also use relative and absolute file system paths). > But visiting 127.0.0.1:3000 there is nothing. > > Must i configure IIS to listen to app.js as start page "index.html" No, Node is the server here: you are literally writing the code that handles http requests and returns the http responses, your own web server that is... (I suggest you sat with Express, if you don't want to reinvent a lot of wheels). > What happens if i invoke app.js as a script src within index.html? You get runtime errors, it's just not written for the browser context. > Can i mix up the node.js code with my vanilla just import them as script SRC? You can have js files where you put some general logic that you want to reuse, and that of course you can share. The rest cannot be shared, one works in the context of a browser hence the various browser DOM's, the other is in the context of Node and Node's object model and libraries. HTH, Julio
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2021-10-14 01:27 -0700 |
| Message-ID | <c9ae1e2b-73b7-4f49-9588-954c2fd7b2f7n@googlegroups.com> |
| In reply to | #40469 |
torsdag 14 oktober 2021 kl. 09:12:43 UTC+2 skrev ju...@diegidio.name: > On Thursday, 14 October 2021 at 04:24:19 UTC+2, jonas.t...@gmail.com wrote: > > I finally decided "try" learn a little node.js. > > So i installed according to. > > https://nodejs.org/en/docs/guides/getting-started-guide/ > > > > And simply copied app.js to my intetpub directory. > That's not what it says: wherever you put app.js, and assuming you have node in your path, you launch it with "node app.js" from the command line after cd-ing to where the file is (in this case: of course you can also use relative and absolute file system paths). > > But visiting 127.0.0.1:3000 there is nothing. > > > > Must i configure IIS to listen to app.js as start page "index.html" > No, Node is the server here: you are literally writing the code that handles http requests and returns the http responses, your own web server that is... (I suggest you sat with Express, if you don't want to reinvent a lot of wheels). > > What happens if i invoke app.js as a script src within index.html? > You get runtime errors, it's just not written for the browser context. > > Can i mix up the node.js code with my vanilla just import them as script SRC? > You can have js files where you put some general logic that you want to reuse, and that of course you can share. The rest cannot be shared, one works in the context of a browser hence the various browser DOM's, the other is in the context of Node and Node's object model and libraries. > > HTH, > > Julio 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." But i think he left out a couple of steps, like it should be run from commandline, i got it running now. 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? For example have a "vanilla script" ask a "node.js" server script what time it is from "browser script"? I just try to get a hang out of how you use it, i do not exactly remember how PHP did work but i think it mostly was generated dynamically at server, and you sent request strings? Why i actually want node.js is for passing lowlatency messaging back and forth user "groups" via server or could i even use it to set up peer to peer communication? I also saw that there was someone that had built a library that invoked ASIO "lowlatency audio" via node.js although it certainly seem out of my skill range. Thanks for explanation, sometimes people just take things for granted writing about them, but i cannot see how anyone should thought that the app.js should been invoked from command line coming from clientside scripting. Could someone point me to a "simplest" example of howto invoke a call to node js server "ask for something and return a string into javascript????" http request???. For example a vanilla script request a node js server script that pass the server clock back "if that is really how it is done". I guess there must be some way for client "browser script" todo serverside requests, and wish i had saved a bit PHP code from some 20 years ago.... Because the communication from script with server is a bit similar or?
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2021-10-14 11:18 +0100 |
| Message-ID | <87wnmfap0m.fsf@bsb.me.uk> |
| In reply to | #40470 |
Jonas Thörnvall <jonas.thornvall@gmail.com> writes: >> On Thursday, 14 October 2021 at 04:24:19 UTC+2, jonas.t...@gmail.com wrote: >> > I finally decided "try" learn a little node.js. >> > So i installed according to. >> > https://nodejs.org/en/docs/guides/getting-started-guide/ >> > >> > And simply copied app.js to my intetpub directory. > 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". The phrase "run your web server using node app.js", with "node app.js" highlighted so it is visually distinct form the English text, will be understood by most readers to mean that you have to run a program (node) passing it an argument (app.js) however it is that you do such things on your system. It's not absurd that you did not know what was meant, but it's very rude to conclude that the fault is entirely that of the "braindead monkey" who wrote this one-page quick guide. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2021-10-14 05:26 -0700 |
| Message-ID | <30351810-4bdc-416a-8cb9-3acc945a7542n@googlegroups.com> |
| In reply to | #40472 |
torsdag 14 oktober 2021 kl. 12:18:05 UTC+2 skrev Ben Bacarisse: > Jonas Thörnvall <jonas.t...@gmail.com> writes: > > >> On Thursday, 14 October 2021 at 04:24:19 UTC+2, jonas.t...@gmail.com wrote: > >> > I finally decided "try" learn a little node.js. > >> > So i installed according to. > >> > https://nodejs.org/en/docs/guides/getting-started-guide/ > >> > > >> > And simply copied app.js to my intetpub directory. > > 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". > The phrase "run your web server using node app.js", with "node app.js" > highlighted so it is visually distinct form the English text, will be > understood by most readers to mean that you have to run a program (node) > passing it an argument (app.js) however it is that you do such things on > your system. > > It's not absurd that you did not know what was meant, but it's very rude > to conclude that the fault is entirely that of the "braindead monkey" > who wrote this one-page quick guide. > > -- > Ben. Well i am all about the easy way, both doing an explaining. But as you say run your webserver using node app.js just isn't sufficial. At least run "node app.js" to make some context, because node is an executable and the argument passed is app.js. So better yet would been run node.exe with parameter app.js from directory where app.js resides. Well if "node.exe" path is known... Ok braindead monkey was a bit harsch i really meant parrot LoL
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2021-10-14 15:37 +0200 |
| Message-ID | <isqq5aFc4phU2@mid.individual.net> |
| In reply to | #40473 |
Jonas Thörnvall: > torsdag 14 oktober 2021 kl. 12:18:05 UTC+2 skrev Ben Bacarisse: >> Jonas Thörnvall <jonas.t...@gmail.com> writes: >> >>>> On Thursday, 14 October 2021 at 04:24:19 UTC+2, >>>> jonas.t...@gmail.com wrote: >>>>> I finally decided "try" learn a little node.js. So i >>>>> installed according to. >>>>> https://nodejs.org/en/docs/guides/getting-started-guide/ [...] > Well i am all about the easy way, both doing an explaining. But as > you say run your webserver using node app.js just isn't sufficial. At > least run "node app.js" to make some context, because node is an > executable and the argument passed is app.js. > > So better yet would been run node.exe with parameter app.js from > directory where app.js resides. Well if "node.exe" path is known... In Linux and macOS there is no "node.exe". > Ok braindead monkey was a bit harsch i really meant parrot LoL You should first try to LEARN how things work. And yes, this includes the very very very BASICS what a command line is and how to set your PATH if needed. And maybe you will even find out that using Linux or at least WSL2 in Windows is usually MUCH easier than using Windows only. -- Arno Welzel https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2021-10-14 15:02 +0100 |
| Message-ID | <87r1cnaelt.fsf@bsb.me.uk> |
| In reply to | #40473 |
Jonas Thörnvall <jonas.thornvall@gmail.com> writes: > torsdag 14 oktober 2021 kl. 12:18:05 UTC+2 skrev Ben Bacarisse: >> Jonas Thörnvall <jonas.t...@gmail.com> writes: >> >> >> On Thursday, 14 October 2021 at 04:24:19 UTC+2, jonas.t...@gmail.com wrote: >> >> > I finally decided "try" learn a little node.js. >> >> > So i installed according to. >> >> > https://nodejs.org/en/docs/guides/getting-started-guide/ >> >> > >> >> > And simply copied app.js to my intetpub directory. >> > 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". >> The phrase "run your web server using node app.js", with "node app.js" >> highlighted so it is visually distinct form the English text, will be >> understood by most readers to mean that you have to run a program (node) >> passing it an argument (app.js) however it is that you do such things on >> your system. >> >> It's not absurd that you did not know what was meant, but it's very rude >> to conclude that the fault is entirely that of the "braindead monkey" >> who wrote this one-page quick guide. > > Well i am all about the easy way, both doing an explaining. But as you > say run your webserver using node app.js just isn't sufficial. I didn't think that that is what I said. > At least run "node app.js" to make some context, because node is an > executable and the argument passed is app.js. That's what the coloured background is supposed to suggest. There's no obvious reason to suppose that quotes are clearer, especially as if you were to actually write the quotes it would not work. > So better yet would been run node.exe with parameter app.js from > directory where app.js resides. Except that would be confusing when the program is called node rather than node.exe. As you can see, it's not easy to cater for every possible misunderstanding. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2021-10-14 07:37 -0700 |
| Message-ID | <2d12d78f-74a8-4d09-8ec4-80a5a876454fn@googlegroups.com> |
| In reply to | #40478 |
torsdag 14 oktober 2021 kl. 16:02:59 UTC+2 skrev Ben Bacarisse: > Jonas Thörnvall <jonas.t...@gmail.com> writes: > > > torsdag 14 oktober 2021 kl. 12:18:05 UTC+2 skrev Ben Bacarisse: > >> Jonas Thörnvall <jonas.t...@gmail.com> writes: > >> > >> >> On Thursday, 14 October 2021 at 04:24:19 UTC+2, jonas.t...@gmail.com wrote: > >> >> > I finally decided "try" learn a little node.js. > >> >> > So i installed according to. > >> >> > https://nodejs.org/en/docs/guides/getting-started-guide/ > >> >> > > >> >> > And simply copied app.js to my intetpub directory. > >> > 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". > >> The phrase "run your web server using node app.js", with "node app.js" > >> highlighted so it is visually distinct form the English text, will be > >> understood by most readers to mean that you have to run a program (node) > >> passing it an argument (app.js) however it is that you do such things on > >> your system. > >> > >> It's not absurd that you did not know what was meant, but it's very rude > >> to conclude that the fault is entirely that of the "braindead monkey" > >> who wrote this one-page quick guide. > > > > Well i am all about the easy way, both doing an explaining. But as you > > say run your webserver using node app.js just isn't sufficial. > I didn't think that that is what I said. > > At least run "node app.js" to make some context, because node is an > > executable and the argument passed is app.js. > That's what the coloured background is supposed to suggest. There's no > obvious reason to suppose that quotes are clearer, especially as if you > were to actually write the quotes it would not work. > > So better yet would been run node.exe with parameter app.js from > > directory where app.js resides. > Except that would be confusing when the program is called node rather > than node.exe. As you can see, it's not easy to cater for every > possible misunderstanding. > > -- > Ben. Ok let settle for "run" so that the reader understand it is an executable binary "running in some environment" I think use and webserver is vague in this context.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2021-10-14 07:46 -0700 |
| Message-ID | <2bce9e78-34db-4e76-864c-1b61cfb6a6fan@googlegroups.com> |
| In reply to | #40479 |
torsdag 14 oktober 2021 kl. 16:37:24 UTC+2 skrev Jonas Thörnvall: > torsdag 14 oktober 2021 kl. 16:02:59 UTC+2 skrev Ben Bacarisse: > > Jonas Thörnvall <jonas.t...@gmail.com> writes: > > > > > torsdag 14 oktober 2021 kl. 12:18:05 UTC+2 skrev Ben Bacarisse: > > >> Jonas Thörnvall <jonas.t...@gmail.com> writes: > > >> > > >> >> On Thursday, 14 October 2021 at 04:24:19 UTC+2, jonas.t...@gmail.com wrote: > > >> >> > I finally decided "try" learn a little node.js. > > >> >> > So i installed according to. > > >> >> > https://nodejs.org/en/docs/guides/getting-started-guide/ > > >> >> > > > >> >> > And simply copied app.js to my intetpub directory. > > >> > 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". > > >> The phrase "run your web server using node app.js", with "node app.js" > > >> highlighted so it is visually distinct form the English text, will be > > >> understood by most readers to mean that you have to run a program (node) > > >> passing it an argument (app.js) however it is that you do such things on > > >> your system. > > >> > > >> It's not absurd that you did not know what was meant, but it's very rude > > >> to conclude that the fault is entirely that of the "braindead monkey" > > >> who wrote this one-page quick guide. > > > > > > Well i am all about the easy way, both doing an explaining. But as you > > > say run your webserver using node app.js just isn't sufficial. > > I didn't think that that is what I said. > > > At least run "node app.js" to make some context, because node is an > > > executable and the argument passed is app.js. > > That's what the coloured background is supposed to suggest. There's no > > obvious reason to suppose that quotes are clearer, especially as if you > > were to actually write the quotes it would not work. > > > So better yet would been run node.exe with parameter app.js from > > > directory where app.js resides. > > Except that would be confusing when the program is called node rather > > than node.exe. As you can see, it's not easy to cater for every > > possible misunderstanding. > > > > -- > > Ben. > Ok let settle for "run" so that the reader understand it is an executable binary "running in some environment" > I think use and webserver is vague in this context. run "node" from commandline/shell with "app.js" as argument/parameter would been nice.... in this context...
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2021-10-14 15:34 +0200 |
| Message-ID | <isqpvhFc4phU1@mid.individual.net> |
| In reply to | #40470 |
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
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2021-10-14 23:59 -0700 |
| Message-ID | <01c6ae2d-83a2-4381-96f6-deb42e848581n@googlegroups.com> |
| In reply to | #40470 |
On Thursday, 14 October 2021 at 10:27:12 UTC+2, jonas.t...@gmail.com wrote: > torsdag 14 oktober 2021 kl. 09:12:43 UTC+2 skrev ju...@diegidio.name: <snip> > "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." > > But i think he left out a couple of steps, like it should be run from commandline, i got it running now. That is *obvious* to anyone who knows what s/he is doing, and was written as it customarily is. You are simply and utterly incompetent, and this at least should be obvious even to you. > Is it something similar to PHP, must the whole code base "vanilla javascript" be generated dynamically thru the server? No: as IIS can serve static files, so can your Node app. > Or can i from the clientside script invole functionality from server? Sure, as usual. The point is, server-side vs client-side, the two realms are independent, just one calls the other. And, just like you would not mix (in your mind to begin with) PHP on the server-side with JS on the client-side, so now you don't confuse the JS on the server-side with the JS on the client-side... But keep also in mind that while PHP is the scripting language and IIS (or Apache, etc.) does all the work, here you write at least part of the code that does what IIS itself does. > For example have a "vanilla script" ask a "node.js" server script what time it is from "browser script"? Besides that "vanilla script" rather hints at those files with logic that can be used in any context. Then again that works as usual: open a link, submit a form, send an ajax request, include a script... Now, I am not saying it is trivial, there are even many professionals who can't keep such distinctions really straight and put stuff all in the wrong places: React for the client-side is nowadays a topical example of an institutionalised layering fuck-up. Anyway, that's another story and you needn't make the same mistakes... > I just try to get a hang out of how you use it, i do not exactly remember how PHP did work but i think it mostly was generated dynamically at server, and you sent request strings? Go through Node's tutorials one at a time and eventually you'll get there. By trial and error, which includes just looking up examples, in 10 years you'll still be wandering. Have fun, Julio
[toc] | [prev] | [next] | [standalone]
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Date | 2021-10-15 18:12 -0700 |
| Message-ID | <8f1011b7-db1e-4cfd-b6dc-65e3a6a979cdn@googlegroups.com> |
| In reply to | #40470 |
Every now and then I ask myself why I stopped actively participating in comp.lang.javascript... jonas.thornvall@gmail.com wrote: > 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". [ ... ] > > But i think he left out a couple of steps, like it should be run from > commandline, i got it running now. ... Then I remember. :-( -- Scott
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2021-10-15 19:18 -0700 |
| Message-ID | <61ee363d-f7fe-47ce-986c-c46240a30207n@googlegroups.com> |
| In reply to | #40488 |
lördag 16 oktober 2021 kl. 03:12:51 UTC+2 skrev Scott Sauyet: > Every now and then I ask myself why I stopped actively participating in > comp.lang.javascript... > jonas.t...@gmail.com wrote: > > 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". [ ... ] > > > > But i think he left out a couple of steps, like it should be run from > > commandline, i got it running now. > ... Then I remember. > > :-( > > -- Scott To be honest Scott i am a bit surprised they chosed the same extension for serverside and clientside javascript. And with phrases like "use" one have to be clairvoyant to know what to do. JT
[toc] | [prev] | [next] | [standalone]
| From | Jon Ribbens <jon+usenet@unequivocal.eu> |
|---|---|
| Date | 2021-10-16 15:04 +0000 |
| Message-ID | <slrnsmlqgl.851.jon+usenet@raven.unequivocal.eu> |
| In reply to | #40488 |
On 2021-10-16, Scott Sauyet <scott.sauyet@gmail.com> wrote: > Every now and then I ask myself why I stopped actively participating in > comp.lang.javascript... > > jonas.thornvall@gmail.com wrote: >> 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". [ ... ] >> >> But i think he left out a couple of steps, like it should be run from >> commandline, i got it running now. > > ... Then I remember. > >:-( It's ok with an appropriate kill-file...
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2021-10-19 23:09 -0700 |
| Message-ID | <b35131c1-79ad-4edd-baad-5d3ab31e865an@googlegroups.com> |
| In reply to | #40490 |
On Saturday, 16 October 2021 at 17:05:01 UTC+2, Jon Ribbens wrote: > On 2021-10-16, Scott Sauyet <scott....@gmail.com> wrote: > > Every now and then I ask myself why I stopped actively participating in > > comp.lang.javascript... > > > > jonas.t...@gmail.com wrote: > >> 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". [ ... ] > >> But i think he left out a couple of steps, like it should be run from > >> commandline, i got it running now. > > > > ... Then I remember. > > > >:-( > It's ok with an appropriate kill-file... Which you post after some technical explanation were given. Stupid sucking cunts and the pollution of all ponds... Eat shit and die. *Plonk* Julio
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2021-10-14 01:43 -0700 |
| Message-ID | <59c3716a-2c09-432c-8822-06b48a007bb2n@googlegroups.com> |
| In reply to | #40469 |
torsdag 14 oktober 2021 kl. 09:12:43 UTC+2 skrev ju...@diegidio.name:
> On Thursday, 14 October 2021 at 04:24:19 UTC+2, jonas.t...@gmail.com wrote:
> > I finally decided "try" learn a little node.js.
> > So i installed according to.
> > https://nodejs.org/en/docs/guides/getting-started-guide/
> >
> > And simply copied app.js to my intetpub directory.
> That's not what it says: wherever you put app.js, and assuming you have node in your path, you launch it with "node app.js" from the command line after cd-ing to where the file is (in this case: of course you can also use relative and absolute file system paths).
> > But visiting 127.0.0.1:3000 there is nothing.
> >
> > Must i configure IIS to listen to app.js as start page "index.html"
> No, Node is the server here: you are literally writing the code that handles http requests and returns the http responses, your own web server that is... (I suggest you sat with Express, if you don't want to reinvent a lot of wheels).
> > What happens if i invoke app.js as a script src within index.html?
> You get runtime errors, it's just not written for the browser context.
> > Can i mix up the node.js code with my vanilla just import them as script SRC?
> You can have js files where you put some general logic that you want to reuse, and that of course you can share. The rest cannot be shared, one works in the context of a browser hence the various browser DOM's, the other is in the context of Node and Node's object model and libraries.
>
> HTH,
>
> Julio
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
let date_ob = new Date();
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World'+date_ob);
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Well i understand howto "echo" information from server now, but i do not quite remember howto request things using client "browser".
I remember that i in PHP did fetch information from a database using forms and input fields that was dynamically created, so i must sent requests via javascript to server?
But i do not remember what such a call "request" looked like.
How would i done the above as a request, via a HTML page with script, for example a button push echoed answer to textarea?
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2021-10-14 15:41 +0200 |
| Message-ID | <isqqclFc77sU1@mid.individual.net> |
| In reply to | #40471 |
Jonas Thörnvall: > Well i understand howto "echo" information from server now, but i do > not quite remember howto request things using client "browser". I Then learn it! The things you need to understand: - HTTP - URL - query parameters - CGI > remember that i in PHP did fetch information from a database using > forms and input fields that was dynamically created, so i must sent > requests via javascript to server? But i do not remember what such a > call "request" looked like. You just send a request with your browser and the server will process it. This request can be: - URL with or without any query parameter (<a href="...">...</a>). - A form which gets submitted (<form action="..." ...></form>) - An XHR request using JavaScript > How would i done the above as a request, via a HTML page with script, > for example a button push echoed answer to textarea? Go and get a book about how HTTP, CGI etc. works. To explain this *here* is WAY OFF TOPIC! -- Arno Welzel https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2021-10-14 07:02 -0700 |
| Message-ID | <93ed9749-367d-4f39-99ad-4bb1848cbde8n@googlegroups.com> |
| In reply to | #40476 |
torsdag 14 oktober 2021 kl. 15:41:46 UTC+2 skrev Arno Welzel: > Jonas Thörnvall: > > Well i understand howto "echo" information from server now, but i do > > not quite remember howto request things using client "browser". I > Then learn it! > > The things you need to understand: > > - HTTP > - URL > - query parameters > - CGI > > remember that i in PHP did fetch information from a database using > > forms and input fields that was dynamically created, so i must sent > > requests via javascript to server? But i do not remember what such a > > call "request" looked like. > You just send a request with your browser and the server will process > it. This request can be: > > - URL with or without any query parameter (<a href="...">...</a>). > - A form which gets submitted (<form action="..." ...></form>) > - An XHR request using JavaScript > > How would i done the above as a request, via a HTML page with script, > > for example a button push echoed answer to textarea? > Go and get a book about how HTTP, CGI etc. works. To explain this *here* > is WAY OFF TOPIC! > -- > Arno Welzel > https://arnowelzel.de Well evidently the requests was simpler then i expected/remember. So i just make a form and send the request, can't quite remember hot it is piped back to form though. I will have to read up, looking at examples "no matter how crazy LoL".
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web