-
Notifications
You must be signed in to change notification settings - Fork 79
HTTPServlet Handler Example
tka edited this page Feb 18, 2013
·
8 revisions
- Save this file to
http_servlet_handler.rb
, and put it in your project's root folder - create
something.html.php
, write some php code - open
http://127.0.0.1:24680/something.php
you will see the page
class PHPHandler
def initialize(app)
@app = app
end
def call(env)
if env["PATH_INFO"] =~ /\/$/
env["PATH_INFO"] += "index.php"
end
if env["PATH_INFO"] =~ /\.php$/
php_path = env["PATH_INFO"][1..-1]
body = %x{php #{php_path}}
[200, {"Content-Type" => "text/html"}, [body]]
else
status, headers, body = @app.call(env)
[status, headers, body]
end
end
end
use PHPHandler
- Save this file to
http_servlet_handler.rb
, and put it in your project's root folder - create
something.html.php
, write some php code - open
http://127.0.0.1:24680/something.php
you will see the page
class PHPHandler
def initialize(app)
@app = app
end
def call(env)
if env["PATH_INFO"] =~ /\.php$/
php_path = env["PATH_INFO"][1..-1]
body = %x{php #{php_path}}
[200, {"Content-Type" => "text/html"}, body]
else
status, headers, body = @app.call(env)
[status, headers, body]
end
end
end
use PHPHandler
- Home
- Getting Started
- Preferences
- Use Compass Extensions
- Templates, Layouts, and Partials
- Template Helpers
- CoffeeScript
- Custom Handlers
- Build Project
- Deploy To Heroku
- Fire.app can't be opened because it is from an unindentified developer on Mac OSX 10.8
- FAQ
- CHANGELOG
- Fire.app-使用說明
- Template Helpers (zh tw)
- Templates, Layouts & Partials (zh tw)
- Sublime Text 2 的 Autocomplete 設定方式
- Mac OS X 10.8 (Mountain Lion) 開啟 Fire.app 問題