Guest User

Untitled

a guest
Feb 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. # vim:set fileencoding=utf-8 filetype=ruby
  3. #
  4. # dummy ActiveResouce server with WEBrick
  5. #
  6. $KCODE = 'u'
  7.  
  8. require 'rubygems'
  9. require 'activesupport'
  10. require 'webrick/httpserver'
  11.  
  12. s = WEBrick::HTTPServer.new(:Port=>10080)
  13. trap("INT"){s.shutdown}
  14. s.mount_proc("/todos.xml") do |req, res|
  15. res.content_type = "text/xml"
  16. res.body = [
  17. {:id=>1, :title=>"the work", :description=>"work, work, work"},
  18. {:id=>2, :title=>"wash dish", :description=>"keep my family peace"},
  19. ].to_xml(:root=>"todos", :children=>"todo")
  20. end
  21. s.start
Add Comment
Please, Sign In to add comment