Skip to content

nodejs http server ready to host your website localy ,or for learning purposes (no express js) all in nodejs apis .

License

Notifications You must be signed in to change notification settings

null-gman/very-simple-http-server-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

usage

  1. you have nodejs already !!
  2. create the website folder like the /frontEnd to be the root for all your pages .
  3. Run: npm main.js This will automatically look for a folder named frontEnd 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 .

issues may you run into

  1. This is in GNU/Linux, and to solve it, use sudo. If you're on Windows, run the terminal you use as an administrator. image

  2. 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. image

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*/

About

nodejs http server ready to host your website localy ,or for learning purposes (no express js) all in nodejs apis .

Resources

License

Stars

Watchers

Forks