diff options
author | gebele <gebele@in-silico.ch> | 2016-01-22 13:49:16 +0100 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2016-01-22 13:49:16 +0100 |
commit | dfffcd555607ce21645eb481bb151c7873c367ab (patch) | |
tree | 92ae4810064a320ac9be0816c779897a2c5fad0e /application.rb |
initial commit
hard copied nanoparticles.rb and data.json from @helma nano-lazar
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 |