get in Sinatra displays whatever you want when you type the path into the URL. I don't put. How do you call put?
I am trying to run
put '/:name' do |name|
puts "hello " + name
end
How do I actually call this? I type into my browser:
http://localhost:4567/examplename\
but when I read it in my terminal (cmd prompt), it tries to access it as get. What am I missing regarding how put works?
The
putmethod corresponds with an HTTPPUTrequest. If you're making aGET, which is what the browser does by default, you should change that to:If you're talking about "how do I write to the browser" then you need this:
Don't write things to STDOUT with
puts, just return the content you want to be sent. That's how Sinatra works.If you want to make a
PUTrequest you need to tell your tool to use that method. For example, withcurl -X PUT.