-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDriver.rb
31 lines (26 loc) · 811 Bytes
/
Driver.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
##
# @author Kevin Bohinski <[email protected]>
# @version 1.0
# @since 2015-10-7
#
# Project Name: Michael-Scott-API
# Description: Just a simple Sinatra REST API server to learn more about Sinatra/Ruby.
#
# Filename: Driver.rb
# Description: Simple Sinatra app to serve Michael Scott quotes.
# Last Modified: 2016-10-1
#
# Copyright (c) 2015 Kevin Bohinski. All rights reserved.
##
# Inspired by: https://github.com/jamesseanwright/ron-swanson-quotes #
# Importing Sinatra, JSON #
require 'sinatra'
require 'json'
class Driver < Sinatra::Base
set :protection, :except => [:json_csrf]
# If a user get requests path /quote , return a quote. #
get '/quote' do
content_type :json
{ :quote => File.readlines("QuoteData.txt").sample[0..-2], :author => 'Michael Scott' }.to_json
end
end