main
sandyx 11 months ago
parent 39291d5a75
commit 780a8a2df2

@ -1,6 +1,7 @@
#!/usr/bin/ruby
require 'socket'
require 'fileutils'
require './database.rb'
ANSI_GREEN = "\e[32m"
@ -65,6 +66,12 @@ def http_not_found(uri)
return "HTTP/1.1 404 Not Found\r\n\r\n #{tmpl_not_found(uri)}"
end
def despace(dir)
Dir.children(dir).each { |s|
FileUtils.mv("#{s.as_root}", "#{s.delete(' ').as_root}") unless s == s.delete(' ')
}
end
def init_database(db)
#get all files and check if theyre already in the database
keys = db.get(:key)
@ -196,6 +203,7 @@ error("specify root folder") if ROOT.nil?
error("specify port") if PORT.nil?
message("starting server on port: #{PORT}")
despace(ROOT)
init_database(db)
TCPServer.open("127.0.0.1", PORT) { |srv|

Loading…
Cancel
Save