Skip to content

Instantly share code, notes, and snippets.

@enotodden
Created June 30, 2013 00:01
Show Gist options
  • Save enotodden/5893202 to your computer and use it in GitHub Desktop.
Save enotodden/5893202 to your computer and use it in GitHub Desktop.
Turbo request parameters example.
local turbo = require("turbo")
local HelloNameHandler = class("HelloNameHandler", turbo.web.RequestHandler)
function HelloNameHandler:get()
-- Get the 'name' argument, or use 'Santa Claus' if it does not exist
local name = self:get_argument("name", "Santa Claus")
self:write("Hello " .. name .. "!")
end
function HelloNameHandler:post()
-- Get the 'name' argument, or use 'Easter Bunny' if it does not exist
local name = self:get_argument("name", "Easter Bunny")
self:write("Hello " .. name .. "!")
end
local application = turbo.web.Application:new({
{"/hello", HelloNameHandler}
})
application:listen(8888)
turbo.ioloop.instance():start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment