I started studying Node.js on a video site called Dot Installation.
I haven't created an environment yet to watch the video.
This video
http://dotinstall.com/lessons/basic_nodejs/26207
shows how to sort processing by URL, but I have no idea why this is happening in the program.
192.168.000.000/1338/about
When I turned it on, the switch had about in the url, so I understood that it was being processed.
However, when I added /about, I looked for index.html of the about folder in the folder where node.js is located, and I thought that the file was not prepared, so I might get a 403 error.
Why do I read the root js file without going to read the lower hierarchy?
javascript node.js
Web servers are basically "receive requests" and "receive responses."For example, for the example URI, we have sent a request for /about to the 1338 version of the port on the 192.168.000.000 server.The destination and contents are mixed in the URI.
The first thing that matters is who gets the request when you send it to the 1338 version of the port, typically from a Web server like Apache, but this time the node.js program.Therefore, the node.js program is always running and all requests are processed there.If so, Apache will not be involved in it.It may be combined, but in this case it is totally irrelevant.
In the form of publishing HTML files, images, etc. in a directory, such as Apache, the latter part of the URI is considered the location of the file in the request, and the contents of the file are returned as a response.Also, if you didn't specify an html file, you can find index.html.
On the other hand, when a program, such as node.js, handles requests and responses (web applications), it can handle requests (URIs, POST contents, etc.).On the other hand, if you want to return the HTML file as it is, you have to write it down properly in the program.That's the real pleasure, and you can use databases and do calculations.
Why don't you try various things while considering the basics mentioned here?
Node.js has no concept of document routes.
For example, Apache and Tomcat have directories and file structures mapped to URLs below the document root, but Node.js requires mapping itself.
© 2024 OneMinuteCode. All rights reserved.