server.rb 498 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/usr/bin/env ruby

require 'rubygems'
require 'bundler/setup'

require 'sinatra'
require 'haml'

get '/' do
  haml :index
end

post '/extract' do
  haml :extract, locals: {result: %x(ruby extract_amendments.rb #{params['file'][:tempfile].path})}
end

__END__

@@ layout
%html
  %body
    = yield
    
@@ index
%form{action: "/extract", method: "POST", enctype: 'multipart/form-data'}
  %input{type: "file", name: "file"}
  %input{type: "submit"}

@@ extract
%pre= Rack::Utils.escape_html(result)