-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.rb
48 lines (37 loc) · 819 Bytes
/
app.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'sinatra'
require 'data_mapper'
Dir.glob(File.expand_path("#{Dir.pwd}/models/*.rb", __FILE__)).each do |file|
require file
end
configure :development do
enable :logging, :dump_errors, :raise_errors
Sinatra::Application.reset!
use Rack::Reloader
end
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/db/nmap_devel.db")
DataMapper.finalize
DataMapper.auto_upgrade!
get '/' do
@hosts=Host.all()
erb :index
end
get "/host/:id" do
@ports=[]
@host=Host.get(params[:id])
@host.hostname = @host.ip4 if @host.hostname == nil
@title = @host.hostname
erb :host
end
get "/ports" do
@title="Ports"
@ports=Port.all
erb :ports
end
get "/port/:id" do
@port=Port.get(params[:id])
@hosts=[]
@title = @port.port
erb :port
end