Jump to content

Server-Side Scripting/Introduction/Ruby

From Wikiversity

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.

See Also

[edit | edit source]