Created
October 28, 2016 17:06
-
-
Save luizamboni/01ed19ab1b89522478f7fcab8780d56d to your computer and use it in GitHub Desktop.
api from rails app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is used by Rack-based servers to start the application. | |
class Api | |
def initialize app | |
@app = app | |
end | |
def call(env) | |
req = Rack::Request.new env | |
command = req.POST["command"] | |
result = eval(command) | |
[ 200, {"Content-Type" => "text/json"}, [result] ] | |
end | |
end | |
map "/test_api" do | |
use Api | |
end | |
require ::File.expand_path('../config/environment', __FILE__) | |
run Rails.application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment