diff options
Diffstat (limited to 'application.rb')
-rw-r--r-- | application.rb | 26 |
1 files changed, 26 insertions, 0 deletions
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 |