-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.rb
More file actions
34 lines (29 loc) · 761 Bytes
/
service.rb
File metadata and controls
34 lines (29 loc) · 761 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
require 'sinatra'
require 'twitter'
require 'json'
require './memcal.rb'
get '/' do
home_page = <<-HERE.gsub /^\s+/, ""
<h1>Welcome to memtech-service!</h1>
<p>
Check out the project page on <a href="https://github.com/memtech-dev/memtech-service">github</a>.
</p>
<h3>API Features</h3>
<ul>
<li><a href="/tweets">#memtech tweets</a></li>
<li><a href="/calendar">#memtech events in the next month</a></li>
</ul>
HERE
end
get '/tweets' do
content_type :json
tweets = Twitter::Search.new.hashtag("memtech").fetch
output = JSON.generate({
timestamp: Time.now,
tweets: tweets
})
end
get '/calendar' do
content_type :json
MemCal::Calendar.new.simple.to_json
end