Well, the topic is a bit more complicated. Sinatra does not actually reset the server state:
require 'sinatra'
GlobalState = {}
GlobalState[:some_counter] = 0
get '/' do
response = "GlobalState[:some_counter]: #{GlobalState[:some_counter]}"
GlobalState[:some_counter] += 1
response
end
There is nothing wrong with this code: if you run it and go over http://localhost:4567you will see that it GlobalState[:some_counter]grows as expected.
, - :
- Ruby, , . , ,
- -, . :
- : . , Ruby
- : , , ,
- , : , HTTP ( ). :
- : , HTML5 Local Storage...
- : ( , , cookie)
- . , , ; :