I am making a chat app and I can get the page I want but this page does not load the corresponding css nor the js scripts, does anyone have a solution for this please? So far I have this:
Code:
server.js:
var socket = require( './node_modules/socket.io' );
var express = require('./node_modules/express');
var app = express();
var server = require('http').createServer(app);
var io = socket.listen( server );
var port = process.env.PORT || 3000;
var users = [];
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
io.on('connection', function(socket){
socket.on('chat message', function(msg){
io.emit('chat message', 'isto veio do server: ' +msg);
});
});
server.listen(port, function () {
console.log('Server listening on port %d', port);
});
index.html:
...
<link rel="stylesheet" type="text/css" href="/styles/estilos.css"> <!-- este não carrega -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.6/socket.io.js"></script><scriptsrc="scripts/funcs.js"></script> <!-- este não carrega -->
...