-
Notifications
You must be signed in to change notification settings - Fork 1
/
ledgerweb.rb
48 lines (43 loc) · 1000 Bytes
/
ledgerweb.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
require 'rubygems'
require 'sinatra'
get '/' do
s = ""
s +="<form action='/' method='get'>"
s +=" <textarea name='result' rows='40' cols='80'>"
IO.popen( params[:command] ){ |io|
s += io.read
} if params[:command]
s +=" </textarea> <br/>"
s +=" <input name='command' type='text'/>"
s +=" <input type='submit'/>"
s +="</form>"
return s
end
get '/balances/' do
content_type :json
s = ""
IO.popen( 'python accounts.py' ){ |io|
s += io.read
}
return s
end
get '/balances/:account' do
content_type :json
# s = '{"nodes":['
# IO.popen( 'ledger bal '+ params[:account] +' --format=\'{"value":%(quantity(abs(total))), "name":"%(account)", "group":1},\n%/\' --display=\'l==2\' --flat -f drewr.dat' ){ |io|
s = ""
IO.popen( "python accounts.py #{params[:account]}" ){ |io|
s += io.read
}
# s.slice!(-2)
# s += "]}"
return s
end
get '/flows/' do
content_type :json
s = ""
IO.popen("python flows.py \'#{params['accounts']}\'" ){ |io|
s += io.read
}
return s
end