lite-web-server
Advanced tools
Comparing version 1.0.0 to 1.0.1-beta.1633013080
var { WebServer } = require("./index.js") | ||
var server = new WebServer({ | ||
dir: "./lib", | ||
dir: "./", | ||
port: 3000 | ||
@@ -5,0 +5,0 @@ }) |
@@ -19,4 +19,17 @@ const http = require('http') | ||
} else { | ||
var _dir = opt.dir ||opt.directory || "./public"; | ||
if (_dir == "/") { | ||
var __dir = "." | ||
} else if (_dir.endsWith("/")) { | ||
var __dir = _dir.slice(0, -1); | ||
} else { | ||
var __dir = _dir | ||
} | ||
if (__dir.startsWith("/")) { | ||
var dir = "."+__dir | ||
} else { | ||
var dir = __dir | ||
} | ||
var options = { | ||
directory: opt.dir ||opt.directory || "./public", | ||
directory: dir || "./public", | ||
notfound: opt.notfound || `<!DOCTYPE html>\n<html>\n<head>\n<title>404 Not Found</title>\n</head>\n<body>\n<center>\n<h1>404 Not Found</h1>\n</center>\n<hr>\n<center>Node.js lite-webserver</center>\n</body>\n</html>`, | ||
@@ -23,0 +36,0 @@ port: opt.port || 3000 |
{ | ||
"name": "lite-web-server", | ||
"version": "1.0.0", | ||
"version": "1.0.1-beta.1633013080", | ||
"description": "creates simple web server.", | ||
"keywords": [ | ||
"webserver", | ||
"http" | ||
"http", | ||
"web-server" | ||
], | ||
@@ -9,0 +10,0 @@ "homepage": "https://github.com/chasyumen/lite-web-server", |
@@ -5,3 +5,3 @@ # lite-web-server | ||
This will load files from `/public` directory if it's not specified. | ||
This will load files from `./public/` directory if it's not specified. | ||
@@ -15,3 +15,3 @@ ## Install | ||
This server will load files from `/public` directory. | ||
This server will load files from `./public/` directory. | ||
@@ -30,3 +30,3 @@ ```js | ||
var server = new WebServer({ | ||
dir: "./public_html" | ||
dir: "./public_html/" | ||
}) | ||
@@ -58,3 +58,3 @@ | ||
Default: `./public` | ||
Default: `./public/` | ||
@@ -65,3 +65,3 @@ The directory to load the file. | ||
new WebServer({ | ||
dir: "./public_html" | ||
dir: "./public_html/" | ||
}) | ||
@@ -77,3 +77,3 @@ ``` | ||
new WebServer({ | ||
notfound: "File was not found on this server." | ||
notfound: "<center><h1>File was not found on this server.</h1></center>" | ||
}) | ||
@@ -80,0 +80,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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
7318
125
1