blob: dbe6ea9536cab512dfef2086c3a30eb40cbb002e (
plain)
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
|
#!/usr/bin/env ruby
require "sinatra"
require "./lib/maze"
require "./lib/path"
def newmaze
Maze.new(40, 30).generate_random(150)
end
def newpath(maze)
Path.new(maze).generate_astar
end
maze = newmaze
path = newpath(maze)
get "/" do
redirect "maze.html"
end
get "/api/v0.1/maze" do
#redirect "maze.mml"
maze.mml
end
post "/api/v0.1/maze" do
maze = newmaze
maze.mml
end
get "/api/v0.1/path" do
#redirect "path.pml"
path.pml
end
get "/api/v0.1/path/valid" do
#redirect "path.pml"
path.valid? ? "true" : "false"
end
post "/api/v0.1/path" do
path = newpath(maze)
end
|