-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rb
More file actions
69 lines (64 loc) · 1.64 KB
/
main.rb
File metadata and controls
69 lines (64 loc) · 1.64 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'sinatra'
set :environment, :production
#-------------------------------------------------------------------------------
def dirlist()
web_page =<<END
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: black;
font-family: Sans-Serif;
text-align: left;
}
a {
color: white;
font-size: 14pt;
}
a:link {
color: white;
text-decoration: none;
}
a:visited {
color: white;
text-decoration: none;
}
a:hover {
color: red;
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
</style>
</head>
<body>
<hr align="left" width="50%" height="4px" color="white" background-color="white">
END
act_dir = Dir.pwd
var = Dir["#{act_dir}/public/*"]
var.each do
|elem|
if File.directory?("#{elem}") == true
elem.slice! "#{act_dir}/public/"
link = %Q[ <a href="/#{elem}/">[FOLDER]--#{elem}</a></br>]
else
elem.slice! "#{act_dir}/public/"
link = %Q[ <a href="/#{elem}">#{elem}</a></br>]
end
web_page += link + "\n"
end
web_page += %Q[ <hr align="left" width="50%" height="4px" color="white" background-color="white">\n </body>\n</html>]
return web_page
end
#-------------------------------------------------------------------------------
get '/' do
erb :index
end
get '/form' do
erb :form
end
get '/dir' do
dirlist()
end