server.rb 545 Bytes
Newer Older
1 2 3 4 5 6 7
#!/usr/bin/env ruby

require 'rubygems'
require 'bundler/setup'

require 'sinatra'
require 'haml'
8
require './extract_amendments'
9 10 11 12 13 14

get '/' do
  haml :index
end

post '/extract' do
15 16
  result = AmendmentExtractor.new.extract(params['file'][:tempfile].path)
  haml :extract, locals: {result: result}
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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)