大佬教程收集整理的这篇文章主要介绍了Node.js – Socket.io客户端文件不由基本节点Web服务器提供,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用此客户端代码:
<script src="/socket.io/socket.io.js"></script>
我的理解是Node应该选择并解决它?它在一个更简单的Web服务器示例上.
我的Web服务器示例未解析如下:
var server = http.createServer(function (request,responsE) { console.log('request starTing...'); var filePath = '.' + request.url; if (filePath == './') filePath = './index.html'; var extname = path.extname(filePath); var contentType = 'text/html'; switch (extName) { case '.js': contentType = 'text/javascript'; break; case '.css': contentType = 'text/css'; break; } path.exists(filePath,function(exists) { if (exists) { fs.readFile(filePath,function(error,content) { if (error) { response.writeHead(500); response.end(); } else { response.writeHead(200,{ 'Content-Type': contentType }); response.end(content,'utf-8'); } }); } else { response.writeHead(404); response.end(); } });
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); }); }
任何人都可以建议使用第一个Web服务器示例在客户端上不提供socket.io文件的原因是什么?
此致,本.
以上是大佬教程为你收集整理的Node.js – Socket.io客户端文件不由基本节点Web服务器提供全部内容,希望文章能够帮你解决Node.js – Socket.io客户端文件不由基本节点Web服务器提供所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。