From dfffcd555607ce21645eb481bb151c7873c367ab Mon Sep 17 00:00:00 2001 From: gebele Date: Fri, 22 Jan 2016 13:49:16 +0100 Subject: initial commit hard copied nanoparticles.rb and data.json from @helma nano-lazar --- application.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 application.rb (limited to 'application.rb') diff --git a/application.rb b/application.rb new file mode 100644 index 0000000..50f027a --- /dev/null +++ b/application.rb @@ -0,0 +1,26 @@ +require 'json' +require_relative './nanoparticles.rb' + +configure :development do + $logger = Logger.new(STDOUT) +end + +get '/?' do + redirect to('/predict') +end + +get '/predict/?' do + @data = JSON.parse(File.read("./data.json")) + @example = @data[@data.keys.sample]["physchem"] + #@json_example = JSON.pretty_generate(@example) + haml :predict +end + +post '/predict/?' do + size = params[:size].to_i + @input = [] + (1..size).each{|i| @input << [params["input_key_#{i}"], params["input_value_#{i}"].to_f]} + @params = Hash[*@input.flatten] + @prediction = predict @params + haml :prediction +end -- cgit v1.2.3