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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Steps | |
# 1. Install the gem sinatra | |
gem install sinatra | |
# you you skip rdoc and ri using | |
# gem install sinatra --no-rdoc --no-ri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.