option to run on different ports
This commit is contained in:
parent
211c703e76
commit
3aff974d68
@ -5,6 +5,16 @@ require 'rack'
|
|||||||
require 'pygmentize'
|
require 'pygmentize'
|
||||||
require 'redcarpet'
|
require 'redcarpet'
|
||||||
|
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
|
options = { :port => 6789, :verbose => false }
|
||||||
|
OptionParser.new do |opts|
|
||||||
|
opts.banner = "Usage: sharkfrown [options]"
|
||||||
|
|
||||||
|
opts.on('-p', '--port PORT', "Change port (default: #{options[:port]}") { |v| options[:port] = v.to_i }
|
||||||
|
opts.on('-v', '--verbose', "Verbose (show request log)") { |v| options[:verbose] = true }
|
||||||
|
end.parse!
|
||||||
|
|
||||||
class Sharkfrown
|
class Sharkfrown
|
||||||
class PygmentizeHTML < Redcarpet::Render::HTML
|
class PygmentizeHTML < Redcarpet::Render::HTML
|
||||||
def block_code(code, language)
|
def block_code(code, language)
|
||||||
@ -72,8 +82,8 @@ HTML
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Thin::Server.start('0.0.0.0', 6789) do
|
Thin::Server.start('0.0.0.0', options[:port]) do
|
||||||
use Rack::CommonLogger
|
use Rack::CommonLogger if options[:verbose]
|
||||||
use Rack::ShowExceptions
|
use Rack::ShowExceptions
|
||||||
|
|
||||||
run Sharkfrown.new
|
run Sharkfrown.new
|
||||||
|
Loading…
Reference in New Issue
Block a user