]> Lady’s Gitweb - Vocab/blobdiff - scripts/serve.rb
Improve development setup
[Vocab] / scripts / serve.rb
diff --git a/scripts/serve.rb b/scripts/serve.rb
new file mode 100755 (executable)
index 0000000..cf3b14a
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/ruby
+# SPDX-FileCopyrightText: 2025 Lady <https://www.ladys.computer/about/#lady>
+# SPDX-License-Identifier: CC0-1.0
+
+require "webrick"
+
+server = WEBrick::HTTPServer.new(Port: ARGV[0] || 3000, DocumentRoot: "public", DirectoryIndex: ["index.xhtml"])
+trap 'INT' do server.shutdown end
+
+class XHTMLHandler < WEBrick::HTTPServlet::DefaultFileHandler
+  def do_GET request, response
+    super
+    response['Content-Type'] = 'application/xhtml+xml'
+  end
+end
+WEBrick::HTTPServlet::FileHandler.add_handler("xhtml", XHTMLHandler)
+
+server.start
This page took 0.216009 seconds and 4 git commands to generate.