Git Product home page Git Product logo

knod's Introduction

#Knod

Gem Version Build Status Code Climate

Knod is a lightweight HTTP server designed to facilitate front end development when the corresponding back end is missing or incomplete. It responds to GET, PUT, POST, PATCH, and DELETE, serving up, writing to, and deleting from the directory of your choosing. Knod has no dependencies outside of the Ruby standard library.

Installation

Ruby 2.1 and above:

gem install knod

Older versions of Ruby:

gem install knod -v 0.4.4 (does not support PATCH)

Usage

The Knod gem comes with an executable; you can run it from the command line with knod. Knod will default to port 4444 and the current directory. You can change these with command line arguments (-p and -d, respectively).

You can also run it by requiring knod and calling Knod.start. Knod accepts an options hash that lets you change the port, root directory, and logging:

options = {port: 1234, root: './some/directory', logging: false}
Knod.start options

Logging is enabled by default. The server will select an open ephemeral port at random if you pass in 0 as the port.

Knod sanitizes the path on all requests and does not allow access to folders outside of the root directory where it is run.

GET requests map suffixes into MIME types. Data is considered to be application/octet-stream if the content type is unrecognized.

All data from PUT, POST, and PATCH requests is stored as JSON. If the pathway specified in the request does not exist, Knod will create it.

POST requests auto-increment in the specified path and return the id of the file written as JSON (e.g if a POST request led to the server writing 56.json, the server would respond with "{\"id\":56}".

knod's People

Contributors

byroot avatar enocom avatar moserrya avatar

Watchers

 avatar  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.