Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "sinatra"
- require "sequel"
- DB = Sequel.connect('postgres://localhost/blog', :user=>'admin', :password=>'5883328')
- DB.create_table? :articles do
- primary_key :id
- String :title
- Text :content
- Integer :data_create
- end
- class Article < Sequel::Model(:articles)
- end
- get '/' do
- content_type :json
- Article.all.to_json
- end
- get '/:id' do
- content_type :json
- Article[params(:id)].to_json
- end
- post '/'
- Article.create params(:article) # it's no secure
- end
- delete '/:id'
- Article[params(:id)].delete
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement