https.js

var PORT = 8666;//

var http = require('http');
var url=require('url');
var fs=require('fs');
var mine=require('./mine').types;//
var path=require('path'); var server = http.createServer(function (request, response) {
var pathname = url.parse(request.url).pathname;
var realPath = path.join("E:/threeJs", pathname); //这里设置自己的文件名称; var ext = path.extname(realPath);
ext = ext ? ext.slice(1) : 'unknown';
fs.exists(realPath, function (exists) {
if (!exists) {
response.writeHead(404, {
'Content-Type': 'text/plain'
}); response.write("This request URL " + pathname + " was not found on this server.");
response.end();
} else {
fs.readFile(realPath, "binary", function (err, file) {
if (err) {
response.writeHead(500, {
'Content-Type': 'text/plain'
});
response.end(err);
} else {
var contentType = mine[ext] || "text/plain";
response.writeHead(200, {
'Content-Type': contentType
});
response.write(file, "binary");
response.end();
}
});
}
});
});
server.listen(PORT);
console.log("Server runing at port: " + PORT + ".");

mine.js

exports.types = {
"css": "text/css",
"gif": "image/gif",
"html": "text/html",
"ico": "image/x-icon",
"jpeg": "image/jpeg",
"jpg": "image/jpeg",
"js": "text/javascript",
"json": "application/json",
"pdf": "application/pdf",
"png": "image/png",
"svg": "image/svg+xml",
"swf": "application/x-shockwave-flash",
"tiff": "image/tiff",
"txt": "text/plain",
"wav": "audio/x-wav",
"wma": "audio/x-ms-wma",
"wmv": "video/x-ms-wmv",
"xml": "text/xml"
};

启动命令 node https

浏览器打开http://localhost:8666/examples/css2d_label.html

最新文章

  1. Windows操作技巧 之二(持续更新)
  2. host 备份
  3. VIM 中鼠标选择不选中行号
  4. Nginx location 匹配规则
  5. [转]Apache Maven 入门篇 ( 上 )
  6. linq里的select和selectmany操作
  7. ionice
  8. 神马小说:使用opensearch打造高性能搜索服务
  9. PHP之路——微信公众号授权获取用户信息
  10. bzoj3393 [Usaco2009 Jan]Laserphones 激光通讯
  11. 参数修饰符ref,out ,params的区别
  12. Java开源生鲜电商平台-系统架构与技术选型(源码可下载)
  13. java学习——递归
  14. linux cp 命令详解
  15. ruby的sort方法的重新认识
  16. (转)Redis使用详细教程
  17. laravel中设置表单的方式,以及获取表单的提交的数据
  18. Android 编辑框(EditText)属性学习
  19. $.each() 循环遍历完后阻止再执行的办法
  20. JSP,EL和JSTL

热门文章

  1. 关于Python3 打印中文乱码问题
  2. 如何在vue项目中使用md5.js及base64.js
  3. TZ_16_Vue的idea入门
  4. linux apache vhost
  5. WWDC2013 Objective-C 新特性
  6. hdoj 1325 Is It A Tree? 【并查集】
  7. Thinkphp5.0 模型hasOne、hasMany、belongsTo详解
  8. 依赖注入的方式(DI)
  9. Zookeeper 扫盲
  10. Leetcode11.Container With Most Water盛最多水的容器