Created
October 8, 2013 13:43
-
-
Save andrewn/6884876 to your computer and use it in GitHub Desktop.
Run PHP scripts via pow.cx
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
require 'rack' | |
require 'rack-legacy' | |
require 'rack-rewrite' | |
INDEXES = ['index.html','index.php', 'index.cgi'] | |
base_path = Dir.getwd | |
base_path = "/Users/andrew/Projects/oss/tal/talexample" | |
use Rack::Rewrite do | |
base_path = Dir.getwd | |
base_path = "/Users/andrew/Projects/oss/tal/talexample" | |
rewrite %r{(.*/$)}, lambda {|match, rack_env| | |
INDEXES.each do |index| | |
if File.exists?(File.join(base_path, rack_env['PATH_INFO'], index)) | |
return rack_env['PATH_INFO'] + index | |
end | |
end | |
rack_env['PATH_INFO'] | |
} | |
end | |
use Rack::Legacy::Php, base_path | |
use Rack::Legacy::Cgi, base_path | |
run Rack::File.new base_path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment