title: ( NodeJS ) Http server does not load JS/CSS files from folder
body: <p>Good day ,</p>
  
  <p>I've got a small problem with my NodeJS http server. The server doesn't load the CSS/JS files from folder , only from url and i don't know why. I would appreciate if someone could take some time and give me some tips on what went wrong.</p>
  
  <p>Here is the Server Code : </p>
  
  <pre><code>var http = require("http");
  var gs = require("querystring");
  var url = require("url");
  var fs = require("fs");
  
  var server = http.createServer(function (request, response, err) {
  
  //HTML
  if (request.url === "/") {
      sendFileContent(response, "HTML/Login.html", "text/html");
      console.log("Requested URL : " + request.url + "\n");
  }
  else if (request.url === "/main") {
      sendFileContent(response, "HTML/Main_Home.html", "text/html");
      console.log("Requested URL : " + request.url + "\n");
  }
  // JS / CSS / Other formats
  else if (/^\/[a-zA-Z0-9\/]*.js$/.test(request.url.toString(1))) {
      sendFileContent(response, request.url.toString().substring(1), "text/javascript");
  }
  else if (/^\/[a-zA-Z0-9\/]*.css$/.test(request.url.toString())) 
  {        
      sendFileContent(response, request.url.toString().substring(1), "text/css");
  }
  else if (/^\/[a-zA-Z0-9\/]*.json$/.test(request.url.toString())) 
  {
      sendFileContent(response, request.url.toString().substring(1), "application/json");
  }
  else if (/^\/[a-zA-Z0-9\/]*.ts$/.test(request.url.toString())) 
  {
      sendFileContent(response, request.url.toString().substring(1), "text/javascript");
  }
  else if (/^\/[a-zA-Z0-9\/]*.png$/.test(request.url.toString())) 
  {
      sendFileContent(response, request.url.toString().substring(1), "image/png");
  }
  else if (/^\/[a-zA-Z0-9\/]*.jpg$/.test(request.url.toString())) 
  {
      sendFileContent(response, request.url.toString().substring(1), "image/jpeg");
  }
  else 
  {
      console.log("Requested URL : " + request.url + "\n");
      response.end();
  }
  });
  
  server.listen(1337, function () 
  { 
    require("console-stamp")(console, '[HH:MM:ss]');
    console.log("HTTP Server runs on port : 1337");
  
  });
  
  console.log("Server ready....");
  </code></pre>
  
  <p>And here is the <code>Send file content</code> function :</p>
  
  <pre><code>function sendFileContent(response, fileName, contentType){
  fs.readFile(fileName, function (err, data) { 
      if (err) {
          response.writeHead(404);
          response.end("Not Found!");
      }
      else {
          response.writeHead(200, { "Content-Type": contentType });
          response.end(data);
      }
  
  });
  };
  </code></pre>
  
  <p>And this is how i call the files in html</p>
  
  <pre><code>&lt;link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"&gt;
  &lt;link type="text/css" rel="stylesheet" href="../materialize/css/materialize.min.css" media="screen,projection" /&gt;
  &lt;link type="text/css" rel="stylesheet" href="../CSS/App.css" /&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;script type="text/javascript" src="../jquery/jquery-3.2.0.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="../materialize/js/materialize.min.js"&gt;      &lt;/script&gt;
  &lt;script type="text/javascript" src="../Javascript/Main_App.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Thank you for your time !</p>