when i started studying back-end with nodejs i hated it , why ? because most the tutorial out there using express js , then why this was a problem ? .
My philosophy in computer science is to level up in abstraction form bottom to the top, meaning do not learn React before mastering basic web technologies (HTML, CSS, JavaScript). while most back-end tutorial in nodejs do the Opposite .
so i tried to learn by my own with docs for networks , back-end and nodejs api , also some tutorial on YouTube or blogs .
in this repo i wanted to create a simple http-server that serve static website for simple usage and to build on top of it (don't reinvent the wheel) with simple functions without using any npm packages , and to be for learning purposes .
Even though I am still a beginner, there may be some issues or mistakes. Please contribute to the project or report them in the issue section.
- you have nodejs already !!
- create the website folder like the
/frontEnd
to be the root for all your pages . - Run:
npm main.js
This will automatically look for a folder namedfrontEnd
in the current working directory. If this is not the case, use the-root
flag to specify a different directory.
Pass
-root .
to serve the current directory as the website root.if you passed a invalid path the server will crash .
-
This is in GNU/Linux, and to solve it, use
sudo
. If you're on Windows, run the terminal you use as an administrator. -
This error message means that the port you're using for the server on your IPv4 (port 80) is already in use. To solve it, close the other service that is using that port or change the port the server uses in
/main.js
.
in main.js
const HostInfo = {ip : undefined , port :undefined};
HostInfo.ip = getIpv4(); /*you can change the host to localhost(127.0.0.1) insted ipv4*/
HostInfo.port = 80; /*change the port number and check if it free*/