Hey guys! Since we started with the MongoDB course. Just saw the first video, which has some writing code in it, so I thought, I will write some, since ❤ ruby ❤
The link for the class video is – link. You can go ahead have a look and see, what it does. I just wrote a similar code which lets us do the same thing in ruby. Using sinatra( bottle is being used with python in the video)
|
# Steps |
|
# 1. Install the gem sinatra |
|
gem install sinatra |
|
# you you skip rdoc and ri using |
|
# gem install sinatra --no-rdoc --no-ri |
|
# hello_world.rb |
|
# This will manage routes and display the content. |
|
# I am sure, you did watch the video before checking this out. |
|
|
|
require "sinatra" |
|
|
|
set :bind, '127.0.0.1' |
|
set :port, '8080' |
|
|
|
get '/hello/:name' do |
|
"Hello #{params[:name]}!" |
|
end |
|
# just simply run the ruby file that we created. |
|
ruby hello_world.rb |
Thats it folks, we are done. Head over to http”//127.0.0.1:8080/hello/world and see for yourself.
Like this:
Like Loading...
Related