Code Monkey home page Code Monkey logo

lg-challenge's Introduction

#Challenge

Write a program which stores a list of IP addresses. It should accept HTTP requests on port 9999 at three endpoints:

POST /ip/add

The body of the POST will be a JSON encoded list of IP addresses (see below). Do not worry about proper error handling, you can assume the request is correctly formatted.

Your program should add each IP address to its list of IPs if that IP isn't already in the list. Otherwise, just ignore it and move on.

GET /ip/get/<ip_address>

A request to /ip/get/1.2.3.4 should return "1.2.3.4" if that address is in the list of IP addresses, and return an HTTP 500 status code response otherwise.

GET /ip/all

A request to /ip/all should return a JSON-encoded list of all the IP addresses currently in the program's list of IP addresses.

DELETE /ip/all

A DELETE request to /ip/all should remove all IP addresses from the server's list

Installing application

% git clone https://github.com/jkgit/lg-challenge.git
% cd lg-challenge/
% bundle install
% rake db:migrate

Running application

% rails server -p 9999

Running Rails tests (make sure server is running for tests)

% rake db:test:load
% rake test    
% rake spec    

Example JSON IP list

[ "1.2.3.4", "4.5.6.7", "20.253.90.9" ]

lg-challenge's People

Contributors

jkgit avatar

Watchers

James Cloos 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.