config.ru 311 B

12345678910111213141516171819
  1. require 'json'
  2. app = lambda do |env|
  3. if env['PATH_INFO'] == "/plaintext"
  4. [
  5. 200,
  6. { 'Content-Type' => 'text/plain' },
  7. ["Hello, World!"]
  8. ]
  9. else
  10. [
  11. 200,
  12. { 'Content-Type' => 'application/json' },
  13. [{:message => "Hello, World!"}.to_json]
  14. ]
  15. end
  16. end
  17. run app