ws 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +5 -0
- data/bin/ws +5 -0
- data/lib/ws.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -30,6 +30,11 @@ To install, make sure you have the latest version of Ruby and RubyGems installed
|
|
30
30
|
:::text
|
31
31
|
ws -d ~ -p 1337 -v
|
32
32
|
|
33
|
+
### Launch a server and use `default.htm` as the default file to serve.
|
34
|
+
|
35
|
+
:::text
|
36
|
+
ws -i default.htm
|
37
|
+
|
33
38
|
### Show help
|
34
39
|
|
35
40
|
:::text
|
data/bin/ws
CHANGED
@@ -18,6 +18,11 @@ optparse = OptionParser.new do |opts|
|
|
18
18
|
options[:directory] = directory
|
19
19
|
end
|
20
20
|
|
21
|
+
options[:index] = "index.html"
|
22
|
+
opts.on "-i", "--index-file FILENAME", "Specify the file name to use for index files." do |file|
|
23
|
+
options[:index] = file
|
24
|
+
end
|
25
|
+
|
21
26
|
options[:port] = 5000 + options[:directory].hash % 1000
|
22
27
|
opts.on "-p", "--port PORT", Integer, "Specify port to use" do |port|
|
23
28
|
options[:port] = port
|
data/lib/ws.rb
CHANGED
@@ -6,7 +6,7 @@ module WS
|
|
6
6
|
while (conn = server.accept)
|
7
7
|
file = conn.gets.scan(/(?<=\/).*(?=\sHTTP)/)[0].split("/")
|
8
8
|
file_path = File.join(options[:directory], file)
|
9
|
-
file_path = File.join(file_path,
|
9
|
+
file_path = File.join(file_path, options[:index]) if File.directory? file_path
|
10
10
|
mime_type = get_mime_type file_path
|
11
11
|
begin
|
12
12
|
file_handle = File.open(file_path, "r")
|