G
G
Gehot2020-04-06 17:49:06
ruby
Gehot, 2020-04-06 17:49:06

Basic code on Sinatra?

Can you please explain each line of this Sinatra code:

require 'sinatra'

get '/' do
'Hello world!'
end

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Damir Konkov, 2020-05-21
@d4mk0f

If top-level, then something like this: We connect the sinatra library We say that we accept GET requests when accessing the root directory of the web server We specify what our web server will return when accessing a specific path ( / ), the last line is usually the value that the function returns. Closing the previously opened block with the do keyword
require 'sinatra'
get '/' do
'Hello world!'
end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question