simpleserver 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9079741b259d83a8392951ad16fee29b05487fe
4
- data.tar.gz: 0ea81aef7a8a1d09040b5258665248ad488de2ca
3
+ metadata.gz: c52b916480aad8c3f8507356ee7f2b370b89b037
4
+ data.tar.gz: 55df08d6df1f3b1516cda4723a2ec661591c6f8f
5
5
  SHA512:
6
- metadata.gz: ea0e714659044cef46c8ba3a1674be6583cb990aef0c04d13233922e7ba2d96eb5b1892d6664788501562706458993eb8551fb9dc94c3c465b9adcec28859c61
7
- data.tar.gz: 3a0878579edf076b2b7cd4b7970f36c40ee6ada609369d1388f502086562c0e12f96ffbbde0e6214b442c757032e5240965282fafb24ae50074d9e173d76e56b
6
+ metadata.gz: f5416b78fc4c8d66116ead945450cd9dd22e12d7b9b4a6d5293418d1e594332a2afd1594a04391c0d7aefe1d03d019383218be38f90718b77b1b02c4b90e1ca0
7
+ data.tar.gz: 3f0476b1b4f59504916d5a13358ebece3909195343382596defa67e699d31de054b6f5c991c307e3966d1723576e5d61ba4a0d380bd08d017ec47b5559166be0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Simpleserver
2
2
 
3
- TODO: Write a gem description
3
+ A very simple web server, able to find html files located in the same directory from its run location.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ After installation, run `$ simpleserver` from the directory where the html files you want to serve are located. Then, in your web browser, navigate to your IP at the port the webserver is set to (the defaut is 1337). Then, simply append the path to the file you want after the backslash.
22
22
 
23
23
  ## Contributing
24
24
 
data/bin/simpleserver ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ require 'socket'
3
+
4
+ server = TCPServer.new 1337
5
+
6
+ loop do
7
+ client = server.accept
8
+ request = client.gets
9
+ verb, path, protocol = request.split(" ")
10
+ path = "." + path
11
+
12
+ if File.file?(path)
13
+ body = File.open(path, "r"){|file| file.read}
14
+ status = "200 OK"
15
+ else
16
+ body = "File not found\n"
17
+ status = "404 Not Found"
18
+ end
19
+
20
+ response = "#{protocol} #{status}\n"
21
+ response += "Content-Type: text/html\n"
22
+ response += "Content-Length: #{body.length}\n"
23
+ response += "Connection: close\n\n"
24
+ response += body
25
+
26
+ client.puts response
27
+ client.close
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Simpleserver
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simpleserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Lien
@@ -41,7 +41,8 @@ dependencies:
41
41
  description: A really simple server
42
42
  email:
43
43
  - codefellow@aqlien.com
44
- executables: []
44
+ executables:
45
+ - simpleserver
45
46
  extensions: []
46
47
  extra_rdoc_files: []
47
48
  files:
@@ -50,6 +51,7 @@ files:
50
51
  - LICENSE.txt
51
52
  - README.md
52
53
  - Rakefile
54
+ - bin/simpleserver
53
55
  - lib/simpleserver.rb
54
56
  - lib/simpleserver/version.rb
55
57
  - simpleserver.gemspec