CGI Output

Use Ruby as a scripting language for your website.

Ruby Scripts

Hello World

GoDaddy


With it's powerful features, syntax, and more, Ruby can even replace old web programming languages such as Perl and PHP.

Content-type

First, in any cgi/web application, you must first send the correct headers to the browser. If the browser (your user/websurfer's internet program) gets the correct headers, then it will know how to display your page. 99% of all your programs will start sending data back with this one line:

puts "Content-type: text/html\n\n"

This line tells the browser that you are sending it a text-based HTML file, which is what most of the web uses these days. Other options might be images, for example, if your program does something with image files.

Afterwards

After that, you will want to start sending your HTML file, however interpreted by your program. Here's a really simple example:


puts "Content-type: text/html\n\n"

puts <<END
<html>
<body>
Welcome to my simple little Ruby website.<br />
Hello World!
</body>
</html>
END