Output a string to web : HTML « CGI « Ruby






Output a string to web


#!/usr/bin/ruby

# closed_cgi.rb
require 'cgi'
c = CGI.new("html4")
c.out do
  c.html do
    c.h1 { 'Sorry, the Web is closed.' }
  end
end

# Content-Type: text/html
# Content-Length: 137

# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
#   "http://www.w3.org/TR/html4/strict.dtd">
# <HTML><H1>Sorry, the Web is closed.</H1></HTML>

 








Related examples in the same category

1.CGI.escape and CGI.unescape.
2.CGI.escapeHTML
3.CGI.escapeElement
4.CGI.unescapeHTML
5.Generating HTML
6.CGI for creating a web page
7.nested cgi.tag to create HTML document
8.Create a hash of HTTP response headers