How to serve external js file to node.js server -
can me downloaded js file socket.io browser client.and put on js folder...but having problem node.js doesn't serves me external js
<script src="./js/socketio.js"></script>
how serve external js file ?
here app.js server code
var app = require('http').createserver(handler) var io = require('socket.io')(app); var fs = require('fs'); app.listen(8080); function handler (req, res) { fs.readfile(__dirname + '/index.html', function (err, data) { if (err) { res.writehead(500); return res.end('error loading index.html'); } res.writehead(200); res.end(data); }); } io.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); });
thank in advance.
Comments
Post a Comment