1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-12-26 12:06:59 +00:00
haste-server/haste

26 lines
455 B
Text
Raw Normal View History

2011-11-18 23:30:31 +00:00
#! /usr/bin/env ruby
require 'restclient'
require 'json'
# Get the data
data = STDIN.readlines.join
data.strip!
# if there is no data, stop
if data == ''
puts 'no input given'
exit 1
end
# Decide on a server
server = ENV['HASTE_SERVER'] || 'http://localhost:7777'
server.chop! if server.end_with?('/')
# Send the data up
back = RestClient.post "#{server}/documents", data
data = JSON.parse(back)
# Output the url
puts "#{server}/#{data['key']}"