title: nodejs express css and js not loaded
body: <p>I use express on nodejs. The html-file I load doesn't get java-scripts and css-files.</p>
  
  <p>index.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;title&gt;Bootstrap 101 Template&lt;/title&gt;
  
  &lt;!-- Bootstrap --&gt;
  &lt;link href="css/bootstrap.min.css" rel="stylesheet"&gt;
  &lt;/head&gt;
  &lt;body&gt;
       &lt;h1&gt;Hello, world!&lt;/h1&gt;
  
  &lt;!-- jQuery (necessary for Bootstrap's JavaScript plugins) --&gt;
  &lt;script type="" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;        &lt;/script&gt;
  &lt;!-- Include all compiled plugins (below), or include individual files as needed --&gt;
  &lt;script src="js/bootstrap.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my express-part in nodejs:</p>
  
  <pre><code>app.get('/', function(req, res){
  
      console.log(req.path);
  
      fs.readFile('mongo_client/index.html',function (err, data){
          if(!err)
          {
              res.writeHead(200, {'Content-Type': 'text/html','Content-Length':data.length});
              res.write(data);
              res.end();
          }
          else
          {
              res.writeHead(400, {'Content-Type': 'text/html'});
              res.end("index.html not found");
          }
      });
  });
  </code></pre>
  
  <p>The only console.log is "/" once. The css and js file isn't even requested.</p>
  
  <p>Edit:</p>
  
  <p>I used the static middleware but it doesn't work either:</p>
  
  <pre><code>app.use(express.static(__dirname + '/public'));
  app.get('/', function(req, res){
  
      fs.readFile('mongo_client/index.html',function (err, data){
          if(!err)
          {
              res.send(data);;
          }
          else
          {
              res.send("index.html not found");
          }
      });
  });
  </code></pre>
  
  <p>Therefore I put my js and css - data to the public - folder.
  Everytime I try to connect I download the index.html file.
  Does anyone have a working example for a simple webserver using express? Do I have to use the file-reader ... I think there's another way using express-middleware.</p>
  
  <p>I just need a simple example of an express web-server that is supporting css and js ... I can't find anything that's just that basic.</p>