Skip to content

Instantly share code, notes, and snippets.

@jeffjohnson9046
Last active June 3, 2020 23:51
Show Gist options
  • Save jeffjohnson9046/673c864a88e15bde6b72 to your computer and use it in GitHub Desktop.
Save jeffjohnson9046/673c864a88e15bde6b72 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