static-cling
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -43,9 +43,13 @@ var path = require('path'), | ||
var cling = function(options){ | ||
console.log('options', options); | ||
var config = merge(defaults,options); | ||
console.log('starting static server on port ' + config.port ); | ||
console.log('config', config); | ||
http.createServer(function (req, res) { | ||
var uri = url.parse(req.url).pathname; | ||
var filename = path.join(config.root, uri); | ||
console.log('please serve', filename); | ||
console.log('serving from', config.root); | ||
existsCheck(filename, function (exists) { | ||
if (!exists) { | ||
console.log('no exist', filename); | ||
return sendFileNotFound(res); | ||
@@ -55,3 +59,5 @@ } | ||
if (fs.statSync(filename).isDirectory()) { | ||
filename = path.resolve(config.root, path.join(filename, config.filename)); | ||
console.log('isDirectory'); | ||
filename = path.resolve(path.join(filename, config.filename)); | ||
console.log('filename', filename) | ||
if(!existsCheck(filename)){ | ||
@@ -61,2 +67,3 @@ return sendFileNotFound(res); | ||
} | ||
fs.readFile(filename, 'binary', function (err, file) { | ||
@@ -71,2 +78,3 @@ if (err) { | ||
} | ||
var type = mime.lookup(filename); | ||
@@ -73,0 +81,0 @@ res.writeHead(200, { |
{ | ||
"name": "static-cling", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"engines": [ | ||
@@ -5,0 +5,0 @@ "node >=4.2.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6928
12
136