Skip to content

Instantly share code, notes, and snippets.

View daz-codes's full-sized avatar

DAZ daz-codes

View GitHub Profile
@@index
h1 The Flash Farm Shop!
p Choose which animals you would like to buy from our shop.
ul#animals
li
h2 Duck
img src="/duck.png"
form action="/buy/duck" method="POST"
input type="submit" value="Add to Basket" title="Buy me, quack!"
li
@@index
h1 Sinatra Flash
form action="/time" method="POST"
input type="submit" value="What Time Is It?" title="What time is it?"
p The time is #{flash[:time]}
post '/time' do
flash[:time] = Time.now.strftime("%I:%M:%S")
redirect '/'
end
@@index
h1 Sinatra Flash
form action="/time" method="POST"
input type="submit" value="What Time Is It?" title="What time is it?"
p The time is #{@time}
post '/time' do
@time = Time.now.strftime("%I:%M:%S")
redirect '/'
end
@@index
h1 Sinatra Flash
form action="/time" method="POST"
input type="submit" value="What Time Is It?" title="What time is it?"
__END__
@@layout
doctype html
html
head
meta charset="utf-8"
title Sinatra Flash
body
== yield
get '/' do
slim :index
end
enable :sessions
require 'sinatra'
require 'slim'
require 'sinatra/flash'