I created a simple Node JS
program. I have index.html
in the same folder that app.js
is located and external css
and js
files within public/stylesheets/style.css
and /public/javascripts/script.js
directories. When i open the index.html
directly form the browser, css
file is syccessfully linked to the html
file. But when i run node app.js
and navigate to http://localhost:3000
, the index.html
is displayed but any style didn't have effected to it. How can i solve it?
app.js
file is this
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
server.listen(3000);
app.get('/', function(req, res){
res.sendfile(__dirname + '/index.html');
});
index.html
file is this
<html>
<head>
<title>Sanitizor</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="public/javascripts/script.js"></script>
<link rel="stylesheet" type="text/css" href="public/stylesheets/style.css">
</head>
<body>
<h3>hello</h3>
<div id="chat"></div>
<form id="sent-message">
<input size="35" id="message"></input>
<input type="submit"></input>
</form>
</body>
</html>