Alright fixed more bugs
This commit is contained in:
parent
dcea6b2a24
commit
4fcd649b0b
1 changed files with 42 additions and 40 deletions
|
@ -86,53 +86,55 @@ post '/' => sub ($c) { handle_file($c) };
|
||||||
get '/f/:dir/#name' => sub ($c) {
|
get '/f/:dir/#name' => sub ($c) {
|
||||||
my $dir = $c->param("dir");
|
my $dir = $c->param("dir");
|
||||||
my $file = $c->param("name");
|
my $file = $c->param("name");
|
||||||
print $dir, $file . "\n";
|
|
||||||
my $ext = $file;
|
my $ext = $file;
|
||||||
$ext =~ s/.*\.//;
|
$ext =~ s/.*\.//;
|
||||||
$c->render_file( filepath => "f/".$dir . "/" . $file,
|
my $path = "f/".$dir . "/" . $file;
|
||||||
format => 'jpg',
|
#carp "sakisafe warning: could not get file: $ERRNO" unless
|
||||||
|
$c->render(text => "file not found", status => 404) unless -e $path;
|
||||||
|
$c->render_file( filepath => $path,
|
||||||
|
format => $ext,
|
||||||
content_disposition => 'inline'
|
content_disposition => 'inline'
|
||||||
);
|
)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
app->max_request_size( 1024 * 1024 * 100 );
|
||||||
|
|
||||||
app->max_request_size( 1024 * 1024 * 100 );
|
post '/upload' => sub ($c) { handle_file($c) };
|
||||||
|
|
||||||
post '/upload' => sub ($c) { handle_file($c) };
|
app->start;
|
||||||
|
|
||||||
app->start;
|
# Index template
|
||||||
|
|
||||||
# Index template
|
#By default Mojolicious gets the "directory root" from the "public"
|
||||||
|
# directory, so the css and the favicon from the "public" directory,
|
||||||
#By default Mojolicious gets the "directory root" from the "public"
|
# in the root of this repo.
|
||||||
# directory, so the css and the favicon from the "public" directory,
|
__DATA__
|
||||||
# in the root of this repo.
|
|
||||||
__DATA__
|
|
||||||
|
|
||||||
@@ index.html.ep
|
@@ index.html.ep
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>sakisafe</title>
|
<title>sakisafe</title>
|
||||||
<link rel="stylesheet" type="text/css" href="index.css"/>
|
<link rel="stylesheet" type="text/css" href="index.css"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<center>
|
<center>
|
||||||
<h1>sakisafe</h1>
|
<h1>sakisafe</h1>
|
||||||
<h2>shitless file upload, pastebin and url shorter</h2>
|
<h2>shitless file upload, pastebin and url shorter</h2>
|
||||||
<img src="saki.png"/>
|
<img src="saki.png"/>
|
||||||
<h2>USAGE</h2>
|
<h2>USAGE</h2>
|
||||||
<p>POST a file:</p>
|
<p>POST a file:</p>
|
||||||
<code>curl -F 'file=@yourfile.png' https://<%= $c->req->url->to_abs->host; %></code>
|
<code>curl -F 'file=@yourfile.png' https://<%= $c->req->url->to_abs->host; %></code>
|
||||||
<p>Post your text directly</p>
|
<p>Post your text directly</p>
|
||||||
<code>curl -F 'file=@-' https://<%= $c->req->url->to_abs->host; %></code>
|
<code>curl -F 'file=@-' https://<%= $c->req->url->to_abs->host; %></code>
|
||||||
</center>
|
</center>
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<h2>Or just upload a file here</h2>
|
<h2>Or just upload a file here</h2>
|
||||||
<form ENCTYPE='multipart/form-data' method='post' action='/upload'>
|
<form ENCTYPE='multipart/form-data' method='post' action='/upload'>
|
||||||
<input type='file' name='file' size='30'/>
|
<input type='file' name='file' size='30'/>
|
||||||
<input type='submit' value='upload'/>
|
<input type='submit' value='upload'/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Reference in a new issue