How can I make sinatra code respond to below GET method?
http://my.server.address/function?key1=value1&key2=value2&key3=value3
Thanks for your kindness.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since the only thing in the path is ‘/function’, that’s the only thing you have to manage. The host will be dealt with by the server, the params by Sinatra (it makes them available through the
paramsmethod) So we can get this running with this little bit of code:And when we run it locally on port 4567, then go to “http://localhost:4567/function?key1=value1&key2=value2&key3=value3”, it returns our inspected params as
{"key1"=>"value1", "key2"=>"value2", "key3"=>"value3"}As far as the “my.server.address”, that depends on how you’re hosting your application. If you have no experience here, the easiest way to get something like this working is to use Heroku.