'Stéphane Laurent' via sinatrarb
2015-06-21 15:12:48 UTC
Hello,
I'd like to have a simple app example that gets a value from the client and
send a value to the client.
For example, an app taking a value and sending the double :
require 'sinatra'
get '/double' do
erb :html
end
??????
x = params[:x]
result = 2*x
send result to "#result"
??????
__END__
@@html
<!doctype html>
<html>
<header>
<title>Double</title>
</header>
<body>
<p>Enter x:</p>
<input type="number" name="x">
<input type="submit" value="Calculate 2*x">
<p>Result:</p>
<div id="result"></div>
</form>
</body>
</html>
I'd like to have a simple app example that gets a value from the client and
send a value to the client.
For example, an app taking a value and sending the double :
require 'sinatra'
get '/double' do
erb :html
end
??????
x = params[:x]
result = 2*x
send result to "#result"
??????
__END__
@@html
<!doctype html>
<html>
<header>
<title>Double</title>
</header>
<body>
<p>Enter x:</p>
<input type="number" name="x">
<input type="submit" value="Calculate 2*x">
<p>Result:</p>
<div id="result"></div>
</form>
</body>
</html>
--
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sinatrarb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sinatrarb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.