Code Monkey home page Code Monkey logo

nano-server's Introduction

nano-server

nano-server is an ultra-lightweight node.js HTTP server for web development. It exposes a local directory through HTTP, simplifying development of front-end apps that require functionality blocked by cross-origin protections, e.g. AJAX, Canvas Image Processing, Web Audio Analysis, WebGL textures.

nano-server provides some features that I didn't find in similar server packages:

  • Sends gzipped versions of files, if they are available.
  • Attempts to set the Content-Type header with the appropriate MIME type for browser-relevant file types.
  • 0 dependencies. Can be dropped into any project.

Usage

The simplest way to install nano-server is as a global install through npm:

  $ npm install -g nano-server

Then nano-server can be invoked as a command line executable:

  $ nano-server

By default, nano-server will run on port 5000 and use the current working directory as its document root. Optionally, a port number can be passed as first argument on the command line:

  $ nano-server 3000

The document root can be given as second argument, if desired.

  $ nano-server 5000 my_app/public_html

Since nano-server has no dependancies, it can be dropped directly into any project and invoked using node explicitly. This can be useful if you don't have the necessary permissions to do a global install on the machine you're using:

  $ cp nano-server ~/path/to/project/
  $ cd ~/path/to/project/
  $ node nano-server

nano-server's People

Contributors

natacha-beck avatar paulmougel avatar sebhildebrandt avatar tsherif 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nano-server's Issues

Using the npm published version of nano-server on a Unix-based system fails

While trying to use nano-server to serve static files for Brain Browser:

$  nano-server 5000 ./examples
env: node\r: No such file or directory

This happens because the files are saved in DOS format (see npm/npm#2097), which unfortunately screws the shebang…

Edit: I tried to fork the repository and fix the line-endings, but it turns out they are fine! Only the files published on npm are messed up. So I guess re-publishing from a UNIX computer should be enough to fix the issue.


For people encountering the same issue, here is how I fixed it.

The package was installed using npm i -g nano-server, so I edited the file where the program was loaded from:

$ vim $(which nano-server)

just enter :set ff=unix, save the file and voilà!

Reduce number of MIME types

Not sure how useful it is to have all the MIME types. Maybe just reducing it to the ones relevant to the browser would be enough (html, js, css, json, etc.).

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.