Created
August 4, 2009 07:53
-
-
Save mrkn/161087 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# coding: utf-8 | |
require 'webrick' | |
require 'Win32API' | |
require 'rubygems' | |
require 'rack' | |
require 'sinatra' | |
set :run, false | |
get '/' do | |
'Hello, Sinatra [<a href="/server/quit">quit</a>]' | |
end | |
Rack::Handler::WEBrick.run Sinatra::Application, :Port=>0 do |server| | |
trap :INT do | |
server.shutdown | |
end | |
get '/server/quit' do | |
server.stop | |
'sinatra_test is going to be shutdown...' | |
end | |
shell_execute = Win32API.new('shell32.dll', 'ShellExecuteA', %w(p p p p p i), 'i') | |
shell_execute.call(0, 'open', "http://localhost:#{server[:Port]}", 0, 0, 1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment