Git Product home page Git Product logo

sentiment-api-rails's Introduction

Sentiment-API on Rails

Embedded original Sentiment API build using Grape framework into a Rails app

How to use

$ git clone [email protected]:picsoung/sentiment-api-rails.git
$ cd sentiment-api-rails
$ bundle install
$ rails s

The API is available at http://localhost:3000/api/v2/words/hello.json

Step-by-step

  1. Follow @njyx's tutorial about how to implement a simple API using Grape framework and 3scale. link

  2. Create an empty Rails app rails new my-app

  3. Create a directory api under app folder. That's where all your API logic will go.

  4. Create a empyt file api.rb in this new created folder

    If you followed the tutorial that what you should have in your app folder

    $ ls app/
    app
    |-- api.rb
    |-- sentiment/
    |   |-- analyser.rb
    |   |-- sentiment.rb
    |   |-- data/
    |   |   |-- working_AFINN-111.txt
    
  5. in app/api/api.rb

    class API < Grape::API
      prefix 'api' # optional, it makes you api available at myserver.com/api/
      mount Sentiment::Ress
    end
  6. Rename sentiment.rb in app/api/sentiment/ to ress.rb and edit the file so it looks like this

    module Sentiment
      class Ress < Grape::API
    	# Keep API logic like before
      end
    end
  7. Now edit config/application.rb and add those lines to take load new files added

    config.paths.add "app/api", :glob => "**/*.rb"
    config.autoload_paths += Dir["#{Rails.root}/app/api/*"]
  8. Finally modify your routes.rb so it mounts the API class

    mount API => '/'
  9. Your API should be ready to serve. Relaunch your server and try to access it at http://localhost:3000/api/v2/words/hello.json

Deploy to engineyard

  1. Setup a new Application in your Cloud account and add deploy keys to it

  2. Create a new environnement

    • passenger 3
    • ruby of your choice
  3. Launch instance and deploy If the deploy breaks it generally coming from missing gems or assets configuration.

  4. Your API should be accessible :)

sentiment-api-rails's People

Contributors

picsoung avatar

Stargazers

quentin deleglise avatar

Watchers

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