Skip to content

Instantly share code, notes, and snippets.

@muraoka-edo
Created September 29, 2014 06:03
Show Gist options
  • Save muraoka-edo/513d973c0aef4496cec3 to your computer and use it in GitHub Desktop.
Save muraoka-edo/513d973c0aef4496cec3 to your computer and use it in GitHub Desktop.
[Ruby] Webrick(ERB)
#!/usr/bin/env ruby
# coding: utf-8
require 'webrick'
config = {
:Port => 10080,
:DocumentRoot => '.',
}
# Set: ERB Handler
WEBrick::HTTPServlet::FileHandler.add_handler("erb", WEBrick::HTTPServlet::ERBHandler)
# Startup
server = WEBrick::HTTPServer.new( config )
# MimeType(ERB) -> ext/html"
server.config[:MimeTypes]["erb"] = "text/html"
# Trigger(Ctrl-C) -> Shutdown
trap(:INT) do
server.shutdown
end
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment