Project

apphttp

0.0
No commit activity in last 3 years
No release in over 3 years
Makes it trivial to web enable a Ruby project.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.1.0, ~> 0.1
 Project Readme

AppHttp: Viewing the public methods from the index page

require 'apphttp'

class Fun

  def initialize()
  end

  def go()
    'go 123'
  end

  def hello(name)
    'hello ' + name
  end

  def food(apples: 0, grapes: 0)
    {apples: apples, grapes: grapes}
  end

end

rws = AppHttp.new(Fun.new, port: '9292', filepath: '/home/james/tmp/fun', headings: false)
rws.start

In the above example a Ruby object's methods are exposed through a web server. In this latest version a default index page is generated for convenience.

Where a argument is to be supplied a method, a input box is generated for your to enter the argument value, prior to method execution.

Below is a demo of the above example:

An animated gif screencast of the apphttp demo

apphttp


Introducing the apphttp gem

Usage

require 'apphttp'


class Fun

  def initialize()
  end

  def go()
    'go 123'
  end

  def hello(name)
    'hello ' + name
  end

  def food(apples: 0, grapes: 0)
    {apples: apples, grapes: grapes}
  end

end

rws = AppHttp.new(Fun.new, port: '9292', debug: true)
rws.start

The above example runs a simple web server which can query methods from an aribtrary object, in this case from a class called Fun.

Output

http://127.0.0.1:9292/go #=> go 123
http://127.0.0.1:9292/hello?arg=James #=> hello James
http://127.0.0.1:9292/food?apples=34 #=> {"apples":"34","grapes":0}

Resources

apphttp http webserver tcp server