Server-Side Scripting/Introduction/Ruby
Appearance
app.rb
[edit | edit source]# Displays "Hello world!"
#
# References:
# https://en.wikipedia.org/wiki/WEBrick
require 'webrick'
server = WEBrick::HTTPServer.new(:Port => 8000)
server.mount_proc('/') do |request, response|
response.body = "Hello world!"
end
trap("INT") {server.shutdown}
server.start
Try It
[edit | edit source]Copy and paste the code above into the following free online development environment or use your own Ruby compiler / interpreter / IDE.