Sha256: ee475ccfff454df045ec2df611851c2caba52b3d89ec50e1c1f2131c1b001551
Contents?: true
Size: 723 Bytes
Versions: 69
Compression:
Stored size: 723 Bytes
Contents
require 'webrick' class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet def do_POST(request, response) File.open('story', 'w') do |io| io.write(request.body) end response.status = 200 response['Content-Type'] = 'text/html' response.body = "body" end end params = { :Port => 4000, :ServerType => WEBrick::SimpleServer, :BindAddress => "0.0.0.0", :MimeTypes => WEBrick::HTTPUtils::DefaultMimeTypes } server = WEBrick::HTTPServer.new(params) server.mount('/stories', DispatchServlet) server.mount('/', WEBrick::HTTPServlet::FileHandler, File.dirname(__FILE__) + '/..', { :FancyIndexing => true }) trap("INT") { server.shutdown } server.start
Version data entries
69 entries across 69 versions & 12 rubygems