You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
455 B
25 lines
455 B
#! /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']}"
|
|
|