title: Read css/js files with nodejs and express
body: <p>I'm a real noob when it comes to nodejs, jsut started this a couple of days ago. I can't figure out why my js and css files aren't applied. There are no 404 errors so that doesn't seem to be it. I'm trying to read the files using express. I'm getting these console errors in dev tools:</p>
  
  <p>GamblerScript.js:1 Uncaught SyntaxError: Unexpected token &lt;</p>
  
  <p>jquery-2.2.0.min.js:1 Uncaught SyntaxError: Unexpected token &lt;</p>
  
  <p>localhost/:5 Resource interpreted as Stylesheet but transferred with MIME type text/html: "<a href="http://localhost:8080/css/Stylesheet.css" rel="nofollow">http://localhost:8080/css/Stylesheet.css</a>".</p>
  
  <p>(index):9 Uncaught ReferenceError: Run is not defined</p>
  
  <p><strong>Is there any one who can see what i'm doing wrong?</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var http = require('http');
  var fs = require('fs');
  var index = fs.readFileSync('index.html');
  var express = require('express');
  var app = express();
  
  app.get('/', function(req, res) {
    res.sendfile('/index.html');
  });
  app.use(express.static(__dirname + '/public'));
  
  fs.readFile('./index.html', function (err, html) {
      if (err) {
          throw err; 
      }       
      http.createServer(function(request, response) {  
          response.writeHeader(200, {"Content-Type": "text/html"});  
          response.write(html);  
          response.end();  
      }).listen(8080);
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;title&gt;Dices&lt;/title&gt;
      &lt;link rel="stylesheet" href="/css/Stylesheet.css"&gt;
      &lt;script src="/js/GamblerScript.js"&gt;&lt;/script&gt;
      &lt;script src="/js/jquery-2.2.0.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="Run();"&gt;
  &lt;div id="spinboxcontainer"&gt;
      &lt;div class="spinbox"&gt;
          &lt;span class="spinspan"&gt;Dices&lt;/span&gt;
      &lt;/div&gt;
  &lt;div id="container"&gt;
      &lt;div id="spinner1" class="spinner"&gt;
          &lt;div id="D1.1" class="one"&gt;1&lt;/div&gt;
          &lt;div id="D1.2" class="two"&gt;2&lt;/div&gt;
          &lt;div id="D1.3" class="three"&gt;3&lt;/div&gt;
          &lt;div id="D1.4" class="four"&gt;4&lt;/div&gt;
          &lt;div id="D1.5" class="five"&gt;5&lt;/div&gt;
          &lt;div id="D1.6" class="six"&gt;6&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id=container2&gt;
      &lt;div id="spinner2" class="spinner"&gt;
          &lt;div id="D2.1" class="one"&gt;6&lt;/div&gt;
          &lt;div id="D2.2" class="two"&gt;5&lt;/div&gt;
          &lt;div id="D2.3" class="three"&gt;4&lt;/div&gt;
          &lt;div id="D2.4" class="four"&gt;3&lt;/div&gt;
          &lt;div id="D2.5" class="five"&gt;2&lt;/div&gt;
          &lt;div id="D2.6" class="six"&gt;1&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function Run(){
      alert('Welcome');
  var clickNumber = 1; 
  document.getElementById('spinner1').addEventListener("click", function(){
          alert('Your click is number ' + clickNumber + '!');
          document.body.className -= ' WhiteBackground';
          clickNumber = clickNumber + 1;
  });
  
  document.getElementById('spinner2').addEventListener("click", function(){
          alert('Your click is number ' + clickNumber + '!');
          document.body.className += ' WhiteBackground';
          clickNumber = clickNumber + 1;
  });
  };</code></pre>
  </div>
  </div>
  </p>