Last active
December 17, 2015 15:58
-
-
Save fuba/5634924 to your computer and use it in GitHub Desktop.
やっつけgifzo。
これをなんかてきとうな http://gifzo.net/ と同じ長さの URL でうごかして、Gifzo.app のバイナリ書き換えるとうごく(ドメインがばれると勝手にアップロードされるよ!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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