-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.rb
More file actions
39 lines (31 loc) · 742 Bytes
/
main.rb
File metadata and controls
39 lines (31 loc) · 742 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
39
require 'rubygems'
require 'sinatra'
require "sinatra/namespace"
require "sinatra/cors"
require 'anystyle'
# CORS configs
set :allow_origin, "*"
set :allow_methods, "GET,HEAD,POST"
set :allow_headers, "content-type,if-modified-since"
set :expose_headers, "location,link"
# Endpoints
get '/' do
"Hello world! try /api/v1/parse endpoint."
end
namespace '/api/v1' do
get '/status' do
status 200
"OK"
end
get '/parse' do
text = params['text']
if !text
status 401
"text param required!"
else
result = AnyStyle.parse(text)
content_type :json
result.to_json
end
end
end