GithubHelp home page GithubHelp logo

eob / grunt-web-server Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 3.0 122 KB

An HTTP Server task for grunt, similar to Python's SimpleHTTPServer, with Cross-Origin Resource Sharing and No-Cache options.

License: MIT License

JavaScript 100.00%

grunt-web-server's Introduction

grunt-web-server

A Web Server task for grunt similar to Python's SimpleHTTPServer, with Cross-Origin Resource Sharing and No-Cache options.

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-web-server --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-web-server');

The "web_server" task

Overview

In your project's Gruntfile, add a section named web_server to the data object passed into grunt.initConfig().

Please take special note of the foo: "bar" property below. For some reason an extra key with a non-object value is necessary for things to work. Clearly I'm not understanding something about writing a Grunt plugin here... would appreciate a pull or note if anyone knows what I'm doing wrong.

grunt.initConfig({
  web_server: {
    options: {
      cors: true,
      port: 8000,
      nevercache: true,
      logRequests: true
    },
    foo: 'bar' // For some reason an extra key with a non-object value is necessary
  },
})

Options

options.cors

Type: Boolean Default value: true

Whether to send Cross-Origin Resource Sharing headers.

options.port

Type: Int Default value: 1337

What port to server web requests on.

options.nevercache

Type: Boolean Default value: true

If true, then the server will send headers to try to force the browser to request files afresh each time.

options.logRequests

Type: Boolean Default value: true

If true, then the server will log all incoming requests and the HTTP status of their result.

Running

Once you've configured the web server as above, run the web server with:

grunt web_server

Terminate the web server with Ctrl-C

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 2013-09-27 Initial release.

grunt-web-server's People

Contributors

eob avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.