-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rb
62 lines (54 loc) · 1.31 KB
/
main.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
lib = File.expand_path("../app", __FILE__)
$:.unshift(lib)
# Downloaded libraries
# For debugging
require 'better_errors'
require 'binding_of_caller'
require 'pry'
require 'sinatra'
# My libraries
require 'tweelings'
configure :development do
use BetterErrors::Middleware
BetterErrors.application_root = __dir__
end
get '/' do
File.read(File.join('public', 'html/index.html'))
end
post '/fetch_tweets' do
content_type :json
if request.post?
parsedParams = JSON.parse(request.body.read)
Tweelings::View::AjaxView.fetch_tweets(parsedParams)
else
"Hey, what did you, 'spect?"
# TODO: redirect to an error page
end
end
get '/clean_tweets' do
if request.get?
Tweelings::View::AjaxView.clean_tweets
else
"Hey, what did you, 'spect"
# TODO: redirect to an error page
end
end
post '/annotate_tweets' do
content_type :json
if request.post?
parsedParams = JSON.parse(request.body.read)
Tweelings::View::AjaxView.annotate_tweets(parsedParams)
else
"Hey, what did you, 'spect"
# TODO: redirect to an error page
end
end
post '/annotate_tweets_manually' do
if request.post?
parsedParams = JSON.parse(request.body.read)
Tweelings::View::AjaxView.update_tweets(parsedParams)
else
"Hey, what did you, 'spect"
# TODO: redirect to an error page
end
end