Skip to content

Instantly share code, notes, and snippets.

@farahfa
Forked from jeffjohnson9046/sinatra-server.rb
Created February 12, 2018 18:49
Show Gist options
  • Save farahfa/209b3e90c1da2f118467b29b6a812b50 to your computer and use it in GitHub Desktop.
Save farahfa/209b3e90c1da2f118467b29b6a812b50 to your computer and use it in GitHub Desktop.
A simple sinatra server that accepts a POST with JSON content.
# To make this server publicly available on the inter-webs while running from localhost, use ngrok, which can be found here:
# https://ngrok.com/download. Follow the installation instructions for ngrok and start it up:
#
# ./ngrok 4567 # (or whatever port you want to listen on).
#
# ngrok will spit out an ugly but unique URL. After ngrok starts up, you should be able to POST to the sinatra server:
#
# http://6eee766f.ngrok.com/payload
require 'sinatra'
require 'json'
post '/payload' do
push = JSON.parse(request.body.read)
puts "I got some JSON: #{push.inspect}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment