This repository has been archived by the owner on Jan 1, 2023. It is now read-only.
forked from decc/global-calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhi-3-x.rb
82 lines (72 loc) · 2.71 KB
/
hi-3-x.rb
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require './model/global_2050_model'
require 'sinatra'
require 'json'
# --------------------------------------------------------
# make sure gc html is sent on default
# --------------------------------------------------------
get '/' do
send_file "public/glob-calc-v11.html"
end
# --------------------------------------------------------
# sankey data server for prototype 11
# --------------------------------------------------------
get '/serve_sankey_v11/:parameterstring' do
puts "---- start get -------------"
s = params[:parameterstring]
# do some brut force testing and input error fixing --> needs to be improved !
puts "original params = " + s
# !!! ATTENTION: this needs to be flexible for different versions of calculator !!! :
if s.length != 57
s = "111111111111111111111111111111111111111111111111111111111";
puts "corrected params = " + s
end
g = Global2050ModelResult_V11.new
a = []
a << g.calculate_sankey_v11(s)
puts "--------------------------------------------------"
puts a
puts "--------------------------------------------------"
a.to_json
end
# --------------------------------------------------------
# data plus setup server for prototype 11
# --------------------------------------------------------
get '/serve_plus_setup_v11/:parameterstring' do
puts "---- start get -------------"
s = params[:parameterstring]
# do some brut force testing and input error fixing --> needs to be improved !
puts "original params = " + s
# !!! ATTENTION: this needs to be flexible for different versions of calculator !!! :
if s.length != 57
s = "111111111111111111111111111111111111111111111111111111111";
puts "corrected params = " + s
end
g = Global2050ModelResult_V11.new
a = []
a << g.calculate_pathway_plus_setup_v11(s)
puts "--------------------------------------------------"
puts a
puts "--------------------------------------------------"
a.to_json
end
# --------------------------------------------------------
# data server for prototype 11
# --------------------------------------------------------
get '/serve_v11/:parameterstring' do
puts "---- start get -------------"
s = params[:parameterstring]
# do some brut force testing and input error fixing --> needs to be improved !
puts "original params = " + s
# !!! ATTENTION: this needs to be flexible for different versions of calculator !!! :
if s.length != 57
s = "111111111111111111111111111111111111111111111111111111111";
puts "corrected params = " + s
end
g = Global2050ModelResult_V11.new
a = []
a << g.calculate_pathway_v11(s)
puts "--------------------------------------------------"
puts a
puts "--------------------------------------------------"
a.to_json
end