I found a similar issue in SO. but I did n't get a clear idea how to fix it. Node.js - Socket.io client file not being served by basic node web serverNode.js - Socket.io client file not being served by basic node web server Thanks in advance.
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack InternalI found a similar issue in SO. but I did n't get a clear idea how to fix it. Node.js - Socket.io client file not being served by basic node web serverNode.js - Socket.io client file not being served by basic node web server Thanks in advance.
I found a similar issue in SO. but I did n't get a clear idea how to fix it. Node.js - Socket.io client file not being served by basic node web server Thanks in advance.
I found a similar issue in SO. but I did n't get a clear idea how to fix it. Node.js - Socket.io client file not being served by basic node web server Thanks in advance.
I am new to node js. I am following the link. But this always executing the response.writeHead(404); So I can't able to view the index.html http://thecodinghumanist.com/blog/archives/2011/5/6/serving-static-files-from-node-js
This is my web server node js code.
var http = require('http'); var path = require('path'); var fs = require('fs'); http.createServer(function (request, response) { console.log('request starting...'); var filePath = "."+request.url; if (filePath == './') filePath = '/index.html'; else console.log(request.url); var extname = path.extname(filePath); var contentType = 'text/html'; switch (extname) { case '.js': contentType = 'text/javascript'; break; case '.css': contentType = 'text/css'; break; } fs.exists( filePath, function (exists) { console.log(filePath); if (exists) { fs.readFile(filePath, function (error, content) { if (error) { console.log(error); response.writeHead(500); response.end(); } else { response.writeHead(200, { 'Content-Type': 'text/html' }); response.end(content, 'utf-8'); } }); } else { response.writeHead(404); response.end(); } }); }).listen(8125); My questions.
http://localhost:8125 -> index.html http://localhost:8125/firstpage.html -> firstpage.htmlI also tried the same in cloud9 ide.

I found a similar issue in SO. but I did n't get a clear idea how to fix it. Node.js - Socket.io client file not being served by basic node web server Thanks in advance.