Coder Social home page Coder Social logo

static-server's People

Contributors

alaa-eddine avatar arcath avatar bitjson avatar bmcminn avatar camelcased avatar cvan avatar hulvei3 avatar ineluki avatar kamagatos avatar kennedyrose avatar lordvlad avatar lorenmh avatar marciodrosa avatar nbluis avatar olalonde avatar pascalpflaum avatar yanickrochon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

static-server's Issues

Server crashes on symbolic links (Path must be a string)

$ mkdir ~/test/ && cd ~/test/
$ jspm init
$ ln -s jspm_packages/system.js system.js
$ touch index.html
<!-- index.html -->
<html>
<body>
<script src="system.js"></script>
<script src="config.js"></script>
</body>
</html>
$ static-server --follow-symlink

Crashes on navigating to index.html:

$ static-server --follow-symlink

* Static server successfully started.
* Serving files at: http://localhost:9080
* Press Ctrl+C to shutdown.
<-- [GET] /
--> 200 OK / (index.html) 190 Byte (10.451ms)
<-- [GET] /system.js
<-- [GET] /config.js
* Shutting down server

path.js:8
    throw new TypeError('Path must be a string. Received ' +
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:8:11)
    at Object.posix.relative (path.js:496:3)
    at StaticServer.<anonymous> (/usr/local/lib/node_modules/static-server/bin/static-server.js:55:115)
    at emitOne (events.js:90:13)
    at StaticServer.emit (events.js:182:7)
    at /usr/local/lib/node_modules/static-server/server.js:249:22
    at FSReqWrap.oncomplete (fs.js:82:15)

The template notFound does not use the rootPath like index does

For the rootPath to have a value, I have to concatenate the same value to notFound

If I configure the server like the following, it will return 403 forbidden's because the path will not be accessible.

{
  rootPath: './build',
  templates: {
    index: 'index.html',
    notFound: 'index.html'
  }
}

I have to configure it like so for it to work:

{
  rootPath: './build',
  templates: {
    index: 'index.html',
    notFound: 'build/index.html'
  }
}

Optional Browser

Hi,

How can I use the optional browser like Phantom.js? Can you please let me know.

Thanks.

Enabling Clean URLs

It would be nice to be able to serve clean URLs for static sites. For example, an HTML file without the .html extension is treated like an octet-string content type. This prompts the browser to download the file instead of loading it as html.

`sserver` cli-shortcut

can we add sserver cli-shortcut? it’s easier to type, and can be easily autocompleted.

CORS works incorrectly

In my laptop, I use -c * and everything works ok, but in my cloud server, I use the same command line, the Access-Control-Allow-Origin in response headers is wrong.

My cloud server system is Ubuntu, and node version is 8.11.1, npm version 5.6.0

Create an option to start server with directory listing

Directory listing (like apache) is a good feature sometimes we have a directory with a lot of files.

When asked for a directory, instead of opening the default file (index.html), list all files and directories within it.

I think a html page to link each entry is a good idea.

PS: Just to be safe, should only be enabled via parameter not by default.

Server crashes when given invalid range

When the server receives invalid Range, it crashes with the following error:

        res.headers['Content-Range'] = 'bytes=0-' + originalSize;
        ^
ReferenceError: res is not defined
    at parseRanges (C:\Users\JP\AppData\Roaming\npm\node_modules\static-server\server.js:364:9)
    at sendFile (C:\Users\JP\AppData\Roaming\npm\node_modules\static-server\server.js:446:22)
    at C:\Users\JP\AppData\Roaming\npm\node_modules\static-server\server.js:169:9
    at C:\Users\JP\AppData\Roaming\npm\node_modules\static-server\server.js:275:9
    at FSReqWrap.oncomplete (fs.js:95:15)

It seems like the function for parsing ranges isn't passed the res variable.

Silence output

Would you be willing to accept a PR for a flag that will suppress the output of what URLs being fetched?

Add ability difine additional mime types

I'm working with some new file formats and descovered there's no way to quickly add a new mime type to the server. If there was a file to augment or override the existing mime types from the mime module I think it would be really useful.

Happy to do the work if you want to tell me how you'd like to see it done.

Thanks!

Upgrade to Node 4 and 5

... and drop support for Node 0.10, 0.11, and 0.12.

  • Update tests to support let and const and all compatible ES5/6 commonly implemented features
  • Make the server class based
  • Use Promise instead of callbacks to support future async/await

Prevent parent paths

Prevent URI from going above the root path. Paths like /../, or /some/dir/../../../../index should be forbidden; basically, resolve the URI path and if a string /../ is found, reject it.

--no-cache option

would be nice for local developments to force no-cache/expired headers on all files. right now my mobile phone caches the resources to aggressively

Response object is null

Node: 9.4

server.on('request', function (req, res) {
  // req.path is the URL resource (file name) from server.rootPath
  // req.elapsedTime returns a string of the request's elapsed time
});

In this case res is null, so you can't modify f.e headers (I needed to add MIME)

For new node version I suggest node-static

I suggest to just write compatible node versions to readme

add a host option for the static-server CLI

although it's pretty easy to write a wrapper to listen on any 0.0.0.0 or a particular host ip address, but the CLI is used for convenience, why not provide it in default?

Options

-h, --help                 output usage information
-V, --version              output the version number
-p, --port <n>             the port to listen to for incoming HTTP connections
    --host <host-ip>       the host ip address to listen on, can be `0.0.0.0` for any
-i, --index <filename>     the default index file if not specified
-f, --follow-symlink       follow links, otherwise fail with file not found
-d, --debug                enable to show error messages
-n, --not-found <filename> the error 404 file

comparing python -m SimpleHTTPServer by default listen on 0.0.0.0; and python3 provides an option

➸ python3 -m http.server --help
usage: server.py [-h] [--cgi] [--bind ADDRESS] [port]

positional arguments:
  port                  Specify alternate port [default: 8000]

optional arguments:
  -h, --help            show this help message and exit
  --cgi                 Run as CGI Server
  --bind ADDRESS, -b ADDRESS
                        Specify alternate bind address [default: all
                        interfaces]

Doesn't listen IPV6 [::1]

I succeeded to start static-http-server in Windows 10 Linux subsystem Ubuntu 18.06 with fresh- installed nodejs 12.3.1 Server starts and displays port list
Expected: since I'm in IPV6 network both at home and at office, I expect local IPV6 address [::1] like in PING localhost(localhost (::1)) 56 data bytes
Actual: list of irrelevant IPV4 addresses.
Proposed solution: Nodejs supports IPV6 Please, correct static-http-server according nodejs documentation
Chrome and Edge default on Windows 10 is IPV6

`server.on('response')` callback documentation in README.md has the wrong arguments order

Win7 Pro 64bit
Node: v6.0.0
static-server: ^2.0.3

Just hit a bout of confusion with the sample source from the README.md file regarding server.on('response'.... The callback arguments for file and stat are in switched.

// README.md docs...
server.on('response', function (req, res, err, stat, file) {
    console.log(file); // [Object object]               <-- stat object
    console.log(stat); // '/path/to/file/in/question'   <-- file string
}

I'll submit a PR for this, but just curious if there was a design change in the response callback implementation that caused this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.