I cannot make WEBrick display an XHTML page and its associated CSS - the exact same file with an 'html' extension works perfectly, but it fails with an 'xhtml' extension. How can I configure WEBrick to display XHTML and its CSS?.
I've tried this:
require 'webrick'
def start_webrick(config = {})
config.update(:Port => 5000, :DocumentRoot => '\path\to\my\file\')
server = WEBrick::HTTPServer.new(config)
yield server if block_given?
['INT', 'TERM'].each {|signal|
trap(signal) {server.shutdown}
}
server.start
end
start_webrick
I've also tried this:
require 'webrick'
# WEBrick::HTTPUtils::DefaultMimeTypes['xhtml'] = 'application/xhtml+xml'
# var = File.read('/PD/Dev/Data/Web/Public/index.xhtml')
server = WEBrick::HTTPServer.new(:Port => 5000, :DocumentRoot => '\path\to\my\file\')
server.mount_proc('/') {|request, response| response.body}
trap("INT") {server.shutdown}
server.start
I'm using Ruby 2.7, and I've also changed the default Mime type as in the above comment. If I uncomment the 'File.read...' above and change the 'response.body' to 'response = var', I get the file displayed but not as expected.
I'm very new to this and would appreciate any help. Thank you.