commit 4243115b63795f5668d0002d76c736d6543d2488
from: monaco
via: GitHub
date: Fri Jun 23 20:21:19 2023 UTC
Delete paste.pl
commit - 7e027c93c02ce65cbf364e3819b741b02d5044fb
commit + 4243115b63795f5668d0002d76c736d6543d2488
blob - f0e6973a8884c7c880600b9ed5693bfbb23d1d11 (mode 644)
blob + /dev/null
--- paste.pl
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/env perl
-
-use Mojolicious::Lite;
-use DBI;
-use File::Slurp;
-
-# set up the sqlite database
-my $dbh = DBI->connect("dbi:SQLite:dbname=pastes.db","","", { RaiseError => 1, AutoCommit => 1 });
-$dbh->do("CREATE TABLE IF NOT EXISTS pastes (id INTEGER PRIMARY KEY, content TEXT, expires TIMESTAMP)");
-
-# set up the routes
-get '/' => sub {
- my $c = shift;
- $c->render(template => 'index');
-};
-
-post '/' => sub {
- my $c = shift;
- my $content = $c->param('content');
- my $expires = time() + (60 * 60 * 24 * 60); # 60 days from now
- my $id = int(rand(1000000));
- my $sth = $dbh->prepare("INSERT INTO pastes (id, content, expires) VALUES (?, ?, ?)");
- $sth->execute($id, $content, $expires);
- write_file("pastes/$id.txt", $content);
- $c->redirect_to("/$id");
-};
-
-get '/:id' => sub {
- my $c = shift;
- my $id = $c->param('id');
- my $sth = $dbh->prepare("SELECT * FROM pastes WHERE id = ?");
- $sth->execute($id);
- my $paste = $sth->fetchrow_hashref;
- if ($paste) {
- $c->render(template => 'paste', paste => $paste);
- } else {
- $c->render(text => "Paste not found");
- }
-};
-
-# start the app
-app->start;
-
-__DATA__
-
-@@ index.html.ep
-
-
-
- KISSmo Perl Version 0.7 stable
-
-
-
-
-
-
-
-
- KISSmo Perl Version 0.7 stable
-
-
-
-
-
-@@ paste.html.ep
-
-
-
- Paste
-
-
-
-
-
-
-
-
-
- Paste
-
<%= $paste->{content} %>
- Expires: <%= $paste->{expires} %>
-
-