1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Indent examples at the level Markdown expects

This commit is contained in:
Tony Arcieri 2011-10-01 13:27:47 -07:00
parent 1888887d8f
commit 06072d033c

View file

@ -18,24 +18,24 @@ Quick Start
The easiest way to get started with Puma is to install it via RubyGems and then run a Ruby on Rails application. You can do this easily:
$ gem install puma
$ gem install puma
Now you should have the puma_rails command available in your PATH, so just do the following:
$ cd myrailsapp
$ puma_rails start
$ cd myrailsapp
$ puma_rails start
This will start it in the foreground so you can play with it. It runs your application in production mode. To get help do:
$ puma_rails start -h
$ puma_rails start -h
Finally, you can then start in background mode:
$ puma_rails start -d
$ puma_rails start -d
And you can stop it whenever you like with:
$ puma_rails stop
$ puma_rails stop
All of which should be done from your application's directory. It writes the PID of the process you ran into log/puma.pid.
@ -55,21 +55,21 @@ Usage
The examples/simpletest.rb file has the following code as the simplest example:
require 'puma'
require 'puma'
class SimpleHandler < Puma::HttpHandler
def process(request, response)
response.start(200) do |head,out|
head["Content-Type"] = "text/plain"
out.write("hello!\n")
class SimpleHandler < Puma::HttpHandler
def process(request, response)
response.start(200) do |head, out|
head["Content-Type"] = "text/plain"
out.write("hello!\n")
end
end
end
end
h = Puma::HttpServer.new("0.0.0.0", "3000")
h.register("/test", SimpleHandler.new)
h.register("/files", Puma::DirHandler.new("."))
h.run.join
h = Puma::HttpServer.new("0.0.0.0", "3000")
h.register("/test", SimpleHandler.new)
h.register("/files", Puma::DirHandler.new("."))
h.run.join
If you run this and access port 3000 with a browser it will say "hello!". If you access it with any url other than "/test" it will give a simple 404. Check out the Puma::Error404Handler for a basic way to give a more complex 404 message.