summaryrefslogtreecommitdiff
path: root/new/bin/server.rb
diff options
context:
space:
mode:
authormms <git@sapka.me>2024-12-27 00:16:14 +0100
committermms <git@sapka.me>2024-12-27 00:16:14 +0100
commitd3316d0b042ffa550ff56ed4e691c80003dd1414 (patch)
treededf93e497bb3c95b5f952a79b13dc89d3670fcf /new/bin/server.rb
parent9ff71af752746fd4d61e7b5a1f025b1943f60dea (diff)
feat(new): server mode
Diffstat (limited to 'new/bin/server.rb')
-rwxr-xr-xnew/bin/server.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/new/bin/server.rb b/new/bin/server.rb
new file mode 100755
index 0000000..61f7c22
--- /dev/null
+++ b/new/bin/server.rb
@@ -0,0 +1,37 @@
+require_relative "../lib/crys"
+
+module Crys
+ class ServerRunner
+ SPLASH = [
+ <<-HEREDOC
+ ▄████▄ ██▀███ ▓██ ██▓ ██████ ██████ ██▓▄▄▄█████▓▓█████
+▒██▀ ▀█ ▓██ ▒ ██▒ ▒██ ██▒▒██ ▒ ▒██ ▒ ▓██▒▓ ██▒ ▓▒▓█ ▀
+▒▓█ ▄ ▓██ ░▄█ ▒ ▒██ ██░░ ▓██▄ ░ ▓██▄ ▒██▒▒ ▓██░ ▒░▒███
+▒▓▓▄ ▄██▒▒██▀▀█▄ ░ ▐██▓░ ▒ ██▒ ▒ ██▒░██░░ ▓██▓ ░ ▒▓█ ▄
+▒ ▓███▀ ░░██▓ ▒██▒ ░ ██▒▓░▒██████▒▒▒██████▒▒░██░ ▒██▒ ░ ░▒████▒
+░ ░▒ ▒ ░░ ▒▓ ░▒▓░ ██▒▒▒ ▒ ▒▓▒ ▒ ░▒ ▒▓▒ ▒ ░░▓ ▒ ░░ ░░ ▒░ ░
+ ░ ▒ ░▒ ░ ▒░ ▓██ ░▒░ ░ ░▒ ░ ░░ ░▒ ░ ░ ▒ ░ ░ ░ ░ ░
+░ ░░ ░ ▒ ▒ ░░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░
+░ ░ ░ ░ ░ ░ ░ ░ ░ ░
+░ ░ ░
+HEREDOC
+ ]
+
+ def initialize(server_class:, root: )
+ @root = File.expand_path root
+ @server = server_class.new(root: root)
+ end
+
+ def serve
+ puts ""
+ puts SPLASH.sample
+ puts "Serving from: " + root
+ puts ""
+ server.start
+ end
+
+ private
+
+ attr_reader :root, :server
+ end
+end