-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.rb
More file actions
50 lines (37 loc) · 1.02 KB
/
web.rb
File metadata and controls
50 lines (37 loc) · 1.02 KB
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
require 'sinatra'
require 'json'
get '/' do
responseObject = {
"color"=> "#fff000",
"head_url"=> "url/to/your/img/file"
}
return responseObject.to_json
end
post '/start' do
requestBody = request.body.read
requestJson = requestBody ? JSON.parse(requestBody) : {}
# Get ready to start a game with the request data
# Dummy response
responseObject = {
"taunt" => "Ruby Snake",
}
return responseObject.to_json
end
post '/move' do
requestBody = request.body.read
requestJson = requestBody ? JSON.parse(requestBody) : {}
# Calculate a move with the request data
# Dummy response
responseObject = {
"move" => "north", # One of either "north", "east", "south", or "west".
"taunt" => "going north!",
}
return responseObject.to_json
end
post '/end' do
requestBody = request.body.read
requestJson = requestBody ? JSON.parse(requestBody) : {}
# No response required
responseObject = {}
return responseObject.to_json
end