Skip to content

Instantly share code, notes, and snippets.

Created May 24, 2016
Embed
What would you like to do?
require 'sinatra'
require 'sqlite3'
class Pomodoro < Sinatra::Base
get '/' do
erb :index
end
post '/pomodoro/' do
db = SQLite3::Database.open('db/pomodoro.db')
query = "INSERT INTO pomodoros (id, subject, start, end) VALUES (?, ?, ?, ?)"
db.execute(query, params.values_at(:id, :subject, :start, :end))
db.close()
end
patch '/pomodoro/' do
db = SQLite3::Database.open('db/pomodoro.db')
query = "update pomodoros set end=? where id=?"
db.execute(query, params.values_at(:end, :id))
db.close()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment