-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1 lines (1 loc) · 1.1 KB
/
index.js
1
"use strict";var http=require("http");var fs=require("fs");var url=require("url");var path=require("path");var c=require("child_process");http.createServer(function(e,a){var r=url.parse(e.url).pathname;var n=path.extname(r);fs.readFile(r.substr(1),function(e,r){var t=memu(n);if(e){a.writeHead(404,{"Content-Type":t})}else{a.writeHead(200,{"Content-Length":r.length,"Content-Type":t});a.write(r)}a.end()})}).listen(8080);c.exec("start http://localhost:8080/docs/index.html");function memu(e){switch(e){case".html":return"text/html";break;case".css":return"text/css";break;case".jpg":return"image/jpg";break;case".png":return"image/png";break;case".js":return"text/javascript";break;case".json":return"text/json";break;case".jpeg":return"image/jpeg";break;case".gif":return"image/gif";break;case".svg":return"image/svg+xml";break;case".rtf":return"application/rtf";break;case".woff":case".woff2":return"application/x-font-woff";break;case".webm":return"video/webm";break;default:return"text/plain"}}console.log(" \n 请勿关闭本窗口,打开浏览器访问下列地址 \n");console.log(" http://localhost:8080/docs/index.html");