Skip to content

Instantly share code, notes, and snippets.

@ctdean
Created February 5, 2013 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctdean/4716087 to your computer and use it in GitHub Desktop.
Save ctdean/4716087 to your computer and use it in GitHub Desktop.
require "sinatra"
require 'fileutils'
get '/time' do
Time.now.to_s
end
# curl -X PUT -T foo http://localhost:3000/upload/foo
put '/upload/:file' do
input = env["rack.input"]
out_fname = "uploads/#{params[:file]}"
if input.respond_to? :path
FileUtils.cp(input.path, out_fname)
else
File.write(out_fname, input.read)
end
'uploaded'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment