Skip to content

Instantly share code, notes, and snippets.

@capripot
Last active November 29, 2017 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save capripot/7d380d34237cac69b4f9e5ba11a4d2c0 to your computer and use it in GitHub Desktop.
Save capripot/7d380d34237cac69b4f9e5ba11a4d2c0 to your computer and use it in GitHub Desktop.
Create static file server with puma-dev

Create static file server with puma-dev in 1min

Gemfile

source 'https://rubygems.org'
gem 'rack'
gem 'puma'

config.ru

use Rack::Static,
  :urls => ["/images", "/js", "/css"],
  :root => "public"

run lambda { |env|
  [
    200,
    {
      'Content-Type'  => 'text/html',
      'Cache-Control' => 'public, max-age=86400'
    },
    File.open('public/index.html', File::RDONLY)
  ]
}

Activate the server

Go to the folder

cd static-file-server
puma-dev link
open http://static-file-server.dev

Inspired by puma/puma-dev#87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment