Open rmm5t opened 7 years ago
In lieu of serving bare static sites from public, it would be great to get an example of the minimal config (Gemfile
, config.ru
βΒ whatever the bare minimum is that's required) to get a simple static site serving with puma dev.
Managed to run a static page with the following config. As a basement, I used this Heroku Rack setup:
π https://devcenter.heroku.com/articles/static-sites-ruby
$ tree static-site
static-site
βββ Gemfile
βββ config.ru
ββββ public
βββ css
β βββ styles.css
βββ images
β βββ demo.png
βββ index.html
βββ js
βββ app.js
Additional added gem 'puma'
to Gemfile
:
# Gemfile
source 'https://rubygems.org'
gem 'rack'
gem 'puma'
config.ru
is a copy of the Heroku article
# 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)
]
}
$ puma-dev link
$ open http://static-site.dev
Page is running, with images, stylesheets, and javascript π
Opening this for discussion. Related to https://github.com/puma/puma-dev/issues/44.
Pow allows you to serve a completely static website as long as it has a
public
directory. NoGemfile
(with puma) nor a rackup file (config.ru
) is necessary. This effectively becomes a really easy way to serve a virtual host in development for static sites.Is it within the scope of puma-dev to more directly mimic this static
public
directory behavior for completely static sites?Right now, puma-dev will return an
unexpected exit
with the following log for a static site with just apublic
directory and no rackup file.