Add namarara-api executable
This commit is contained in:
parent
5a16bfd588
commit
d6a347e961
1 changed files with 23 additions and 0 deletions
23
exe/namarara-api
Executable file
23
exe/namarara-api
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
$:.insert(0, 'lib')
|
||||
|
||||
require 'namarara'
|
||||
require 'json'
|
||||
require 'sinatra'
|
||||
|
||||
get '/' do
|
||||
<<-EOF
|
||||
Bonjour le monde !
|
||||
EOF
|
||||
end
|
||||
|
||||
post '/single' do
|
||||
json = JSON.parse(request.body.read)
|
||||
expr = json['expr'] || ''
|
||||
vars = json['vars'] || ''
|
||||
puts json.inspect
|
||||
result = Namarara.parse_string(expr, vars, true)
|
||||
JSON.generate(result)
|
||||
end
|
||||
|
Loading…
Reference in a new issue