forked from david11014/photoIso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.rb
76 lines (64 loc) · 2.24 KB
/
server.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
# encoding: utf-8
require 'sinatra'
require 'sinatra/base'
require './setting.rb'
require './log.rb'
class Server < Sinatra::Base
attr_reader :setting
attr_writer :setting
set :port , 8123
@filename = ENV["SETTING_FILE"] || "setting.db"
get '/' do
@setting = Setting.new
s = "#{Time.now.to_s} [EVENT] load setting from web interface\n"
s += "size= #{@setting.size}\n"
s += "model= #{@setting.model}\n"
s += "time = #{@setting.time}\n"
s += "exposure_time = #{@setting.exposure_time}\n"
s += "white_balance =#{@setting.white_balance}\n"
s += "f_number =#{@setting.f_number}\n"
s += "ISO =#{@setting.ISO}\n"
s += "GPS =#{@setting.GPS}\n"
s += "focal_length =#{@setting.focal_length}\n"
log s
erb :index
end
get '/log' do
erb :log
end
get '/setting' do
@setting = Setting.new
@setting["size"] = params.key?("size") ? true : false
@setting["model"] = params.key?("model") ? true : false
@setting["time"] = params.key?("time") ? true : false
@setting["exposure_time"] = params.key?("exposure_time") ? true : false
@setting["white_balance"] = params.key?("white_balance") ? true : false
@setting["f_number"] = params.key?("f_number") ? true : false
@setting["ISO"] = params.key?("ISO") ? true : false
@setting["GPS"] = params.key?("GPS") ? true : false
@setting["focal_length"] = params.key?("focal_length") ? true : false
@setting.write!
p @setting.size
s = "#{Time.now.to_s} [EVENT] setting from web interface\n"
s += "key = {set value} {receive value}\n"
s += "size= #{@setting.size} #{@params["size"]}\n"
s += "model= #{@setting.model} #{@params["model"]}\n"
s += "time = #{@setting.time} #{@params["time"]}\n"
s += "exposure_time = #{@setting.exposure_time} #{@params["exposure_time"]}\n"
s += "white_balance =#{@setting.white_balance} #{@params["white_balance"]}\n"
s += "f_number =#{@setting.f_number} #{@params["f_number"]}\n"
s += "ISO =#{@setting.ISO} #{@params["ISO"]}\n"
s += "GPS =#{@setting.GPS} #{@params["GPS"]}\n"
s += "focal_length =#{@setting.focal_length} #{@params["focal_length"]}\n"
log s
erb :index
end
private
def tr(t)
if t == "true"
return true
else
return false
end
end
end