The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

markrbower (13) [Avatar] Offline
#1
Have been running the examples as I go and am enjoying the book. The explanations have been thorough, until I ran into listing 6.15, which had a cryptic note "Executing this example ... requires running a server." The linked website helped me get a http-server running on my machine, but I still can't get the example to run. I've started the http-server and can access it from a browser, but then how do I point my JavaScript code at the server? What would be helpful would be a step-by-step guide, much like what is done for each example in the book: "1. start the http-server, 2. ..."

Thanks!
Josip Maras (30) [Avatar] Offline
#2
Hi,

You can, for example install: https://www.npmjs.com/package/http-server (and to run npm, you need to install node: https://nodejs.org/en/).

Once you've done that, through your console, navigate to the book's source code folder (the one with folders chapter-01, chapter-02, etc.), and run: http-server.

This will start a local server at: localhost:8081. You can open that location using your browser, and through it navigate to http://localhost:8081/chapter-06/listing-6.15.html.

Josip
markrbower (13) [Avatar] Offline
#3
Perfect! It took a bit of twiddling with the address, but it makes sense once you realize that the http-server considers the directory in which it starts to be the "root" or "home" directory. While easy to install, the http-server website is quite limited in regards to "help" or tutorials.

For my case, http-server gave the following notice:
$ http-server
Starting up http-server, serving ./
Available on:
  http://127.0.0.1:8080
  http://10.0.0.195:8080
Hit CTRL-C to stop the server


In my browser (Safari), I had to type
http://127.0.0.1:8080/chapter-06/listing-6-15.html

where I had to make sure that the URL address (127.0.0.1:8080) in the address I gave the browser. I point this out for others who are as familiar with running servers as I am (which is "not").

I'm sure this is trivial to those who already know, but such info is sometimes the hardest to find when you don't know.

Thank you!
Mark