Skip to content

Instantly share code, notes, and snippets.

@mayfer
Created August 22, 2014 17:16
Show Gist options
  • Save mayfer/5ae4c63130fd366c9d73 to your computer and use it in GitHub Desktop.
Save mayfer/5ae4c63130fd366c9d73 to your computer and use it in GitHub Desktop.
A simple example demonstrating sending POST data from an HTML form
require 'sinatra'
get '/' do
<<-eos
<html>
<head>
<title>coffee orbit</title>
</head>
<body>
<form method='post' action='/new_message'>
Message: <input type='text' name='message' />
<input type='submit' name='Send' />
</form>
</body>
</html>
eos
end
post '/new_message' do
"you sent: #{params[:message]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment