Code Monkey home page Code Monkey logo

drinks-i-like's Introduction

About

This is a fork of the awesome drinks_i_like(https://github.com/bryanesmith/drinks-i-like) with the following changes:

Install

  • Install a newish perl with plenv(https://github.com/tokuhirom/plenv)
  • Install cpanminus with plenv install-cpanm
  • Install carton with cpanm carton
  • Install perl dependancies carton install
  • Install bower (and nodejs)
  • Install javascript dependancies bower install

Run

  1. Run bin/server:

carton exec bin/server [Wed May 16 10:18:52 2012] [info] Server listening (http://*:3000) Server available at http://127.0.0.1:3000.

You can modify the PORT variable in this script to select a different port.

  1. In your browser, visit: http://127.0.0.1:3000

Restful Interface

For each of the following, if you visit the site's home page (http://127.0.0.1/ by default), you can run the specified jQuery command from the JavaScript console in your browser to test the functionality.

For more information on building a RESTful interface, see: [http://goo.gl/YjyDM]

  1. (Create) To add a drink: POST /api/drink/
    jQuery.post("/api/drink", {
      "title": "Espresso",
      "description": '"It is inhumane, in my opinion, to force people who have a genuine medical need for coffee to wait in line behind people who apparently view it as some kind of recreational activity." - Dave Barry',
    }, function (data, textStatus, jqXHR) {
        console.log("Response: "); 
        console.dir(data); 
        console.log(textStatus); 
        console.dir(jqXHR);
    });
  1. (Read) To get a drink: GET /api/drink/:id
    jQuery.get("/api/drink/1", function(data, textStatus, jqXHR) {
            console.log("Response: ");
      console.dir(data);
      console.log(textStatus);
      console.dir(jqXHR);
    });

Or to get all drinks: GET /api/drink/

    jQuery.get("/api/drink/", function (data, textStatus, jqXHR) {
            console.log("Response: ");
        console.dir(data);
        console.log(textStatus);
        console.dir(jqXHR);
    });
  1. (Update) To update a drink: PUT /api/drink/:id
    jQuery.ajax({
        url: "/api/drink/1",
        type: "PUT",
        data: {
          "description": '"Baby mammals drink milk, and you sir, are a baby mammal." - Mark Rippetoe'
        },
        success: function (data, textStatus, jqXHR) {
            console.log("Response: ");
            console.dir(data);
            console.log(textStatus);
            console.dir(jqXHR);
        }
    });
  1. (Delete) To delete a drink: DELETE /api/drink/:id
    jQuery.ajax({
        url: "/api/products/1", 
        type: "DELETE",
        success: function (data, textStatus, jqXHR) {
            console.log("Response: ");
            console.dir(data); 
            console.log(textStatus); 
            console.dir(jqXHR); 
        }
    });

Useful Resources

drinks-i-like's People

Contributors

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