Add namarara-api executable

This commit is contained in:
Glenn Y. Rolland 2019-12-21 20:30:16 +01:00
parent 5a16bfd588
commit d6a347e961

23
exe/namarara-api Executable file
View 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