xin/bins/ix.nix

37 lines
649 B
Nix
Raw Normal View History

2023-09-12 08:44:05 -06:00
{ perl }: ''
2022-08-25 12:21:35 -06:00
#!${perl}/bin/perl
use strict;
use warnings;
use HTTP::Tiny;
if ($^O eq "openbsd") {
require OpenBSD::Pledge;
require OpenBSD::Unveil;
OpenBSD::Unveil::unveil("/", "") or die;
OpenBSD::Pledge::pledge(qw( stdio dns inet rpath )) or die;
}
my $http = HTTP::Tiny->new();
sub slurp {
my ($fh) = @_;
local $/;
<$fh>;
}
2023-10-12 08:06:55 -06:00
sub ix {
2022-08-25 12:21:35 -06:00
my ($input) = @_;
2023-12-21 09:38:04 -07:00
my $url = "http://sprunge.us";
my $form = [ sprunge => $input ];
2022-08-25 12:21:35 -06:00
my $resp = $http->post_form($url, $form)
or die "could not POST: $!";
$resp->{content};
}
my $input = slurp('STDIN');
2023-10-12 08:06:55 -06:00
my $url = ix($input);
2022-08-25 12:21:35 -06:00
print $url;
''