Skip to content

Instantly share code, notes, and snippets.

@fuba
Last active December 17, 2015 15:58
Show Gist options
  • Save fuba/5634924 to your computer and use it in GitHub Desktop.
Save fuba/5634924 to your computer and use it in GitHub Desktop.
やっつけgifzo。 これをなんかてきとうな http://gifzo.net/ と同じ長さの URL でうごかして、Gifzo.app のバイナリ書き換えるとうごく(ドメインがばれると勝手にアップロードされるよ!)
#!/usr/bin/perl
use strict;
use warnings;
use Amon2::Lite;
use File::Copy;
use File::Basename;
# かきかえてね!
my $root = '/var/www/pi/m';
my $url = 'http://pi.fuba.me/m/';
get '/' => sub {
my $c = shift;
return $c->create_response(200, [], ['Hello, world!']);
};
post '/' => sub {
my $c = shift;
my $path = $c->req->upload('data')->path;
my $filename = basename($path);
my $new_path = $root.'/'.$filename;
move $path, $new_path;
chmod 0666, $new_path;
my $new_url = $url.$filename;
return $c->create_response(200, [], [$new_url]);
};
__PACKAGE__->to_app();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment