Sha256: 8c58426e8c8871652abb4a1c44f074da831d9656e2256cd6398cd5b7e1e5152a

Contents?: true

Size: 866 Bytes

Versions: 5

Compression:

Stored size: 866 Bytes

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'sinatra'
require 'erb'

disable :logging
STDOUT.sync = true

get '/' do
  erb :index
end

get '/form' do
  erb :form
end

post '/form' do
  erb :form_output
end

get '/table' do
  erb :table
end

get '/upload' do
  erb :upload_form
end

post '/upload' do
  unless params[:upload] &&
      (tmpfile = params[:upload][:tempfile]) &&
      (name = params[:upload][:filename])
    "No file selected"
  else
    "File #{name} uploaded"
  end
end

get '/protected' do
  auth = Rack::Auth::Basic::Request.new(request.env)
  if auth.provided? && auth.basic? && auth.credentials &&
      auth.credentials == ['username', 'password']
    "Authorized!"
  else
    response['WWW-Authenticate'] = %(Basic realm="Protected")
    throw :halt, [ 401, 'Authorization Required' ]
  end
end

get '/blank_form' do
  erb :blank_form
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mechanical-cuke-0.5.0 test/fixtures/server/server.rb
mechanical-cuke-0.4.3 test/fixtures/server/server.rb
mechanical-cuke-0.4.2 test/fixtures/server/server.rb
mechanical-cuke-0.4.1 test/fixtures/server/server.rb
mechanical-cuke-0.4.0 test/fixtures/server/server.rb