-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrecognizer_api.rb
More file actions
41 lines (32 loc) · 823 Bytes
/
recognizer_api.rb
File metadata and controls
41 lines (32 loc) · 823 Bytes
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
$:.unshift(File.join(File.dirname(__FILE__), "lib"))
%w(gst rubygems builder sinatra timeout recognizer bundler recognizer_pool
recognizer_session rufus/scheduler json benchmark configure helpers).each{|lib| require lib}
Gst.init
Bundler.require
post '/recognizer' do
begin
session = RecognizerSession.new
session.pool!
render_with_type(session)
rescue Exception => e
render_error(e.message)
end
end
put '/recognizer/:id' do
work_with_session
end
put '/recognizer/:id/end' do
work_with_session(true)
end
get '/recognizer/:id' do
begin
session = RecognizerPool.find_by_session_id(params[:id])
if session
render_with_type(session)
else
render_error("Session with id #{params[:id]} not found")
end
rescue Exception => e
render_error(e.message)
end
end