Getting started with Sinatra on Windows

Just trying to do some very basic web sites/services with Sinatra on
Windows.

I got sinatra installed. I made a very basic web service. Problem is
when I run it, Sinatra fires up and runs fine. However when I browse to
localhost:4567 I see nothing in the browser (tried IE, chrome, and
firefox). I do however see the terminal window process the request,
which looks successful. Just not sure how I get something writing to
the browser. My first sample code:

require “sinatra”
get “/” do
name = “Sinatra”
puts “hello #{name}, I’m in a web browser!”
end

Basic stuff, but nothing in the browser. No idea what I’m doing wrong
here.

puts "hello #{name}, I'm in a web browser!" returns nil, which is the
return value of the block - the response your browser is getting.

The string “hello #{name}, I’m in a web browser!” is enough.

Vlad M_ wrote in post #1155537:

puts "hello #{name}, I'm in a web browser!" returns nil, which is the
return value of the block - the response your browser is getting.

The string “hello #{name}, I’m in a web browser!” is enough.

The return value of the route block is what Sinatra uses as the response
to send back to the browser.

The return value of a block is whatever a return statement specifies OR
if no return statement is specified, the return value is
the result of the last statement that executes in the block.

The last statement that executes in your route block is a puts
statement, and puts returns nil, hence the block returns nil, which when
converted to a String is a blank string–which is what Sinatra uses for
the response. That’s why NO Sinatra tutorial ever uses a puts statement
for the text of the response.