Sha256: 0f76e5fac5b2ef4a5e0eae6cd78ad5f3b9706b6b0a40c91f5d9a759fb7f69afb
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
require 'rainbow' require 'rack' require 'thin' module Zine # Local preview web server class Server def initialize(root) motd Thin::Server.start('127.0.0.1', 8080) do use Rack::Static, urls: ['/'], index: 'index.html', root: root now = Time.now a_long_time = 100**4 run lambda { |_env| [200, { 'Content-Type' => 'text/html', 'ETag' => nil, 'Last-Modified' => now + a_long_time, 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'Pragma' => 'no-cache', 'Expires' => now - a_long_time }, File.open(File.join(root, 'index.html'), File::RDONLY)] } end end def motd puts "\nPreview running on " + Rainbow('http://127.0.0.1:8080/').blue.underline + "\nCommand double click the URL to open, Control C to quit\n" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zine-0.2.0 | lib/zine/server.rb |
zine-0.1.0 | lib/zine/server.rb |