From cf9159cdd0173282b466d702c615fa92f2ecfe15 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 12 Jan 2017 21:13:44 +0100 Subject: wat --- index.pl | 60 +++++++++++++++++++++++++++++++++++++++ templates/layouts/default.html.ep | 19 +++++++++++++ templates/main.html.ep | 1 + 3 files changed, 80 insertions(+) create mode 100644 index.pl create mode 100644 templates/layouts/default.html.ep create mode 100644 templates/main.html.ep diff --git a/index.pl b/index.pl new file mode 100644 index 0000000..072ecf0 --- /dev/null +++ b/index.pl @@ -0,0 +1,60 @@ +#!/usr/bin/env perl + +use Mojolicious::Lite; +use Data::Dumper; +use DBI; +use 5.020; +use utf8; + +our $VERSION = qx{git describe --dirty} || '0.00'; + +my $dbh = DBI->connect( "dbi:SQLite:dbname=picomon.sqlite", q{}, q{} ); + +$dbh->do(qq{ + create table if not exists hostdata ( + hostname text not null unique, + integer last_contact not null, + load1 integer, + load5 integer, + load15 integer, + uptime integer + ) +}); + +app->defaults( layout => 'default' ); +app->attr( dbh => sub { return $dbh } ); + +get '/' => sub { + my ($self) = @_; + + $self->render( + 'main', + version => $VERSION, + ); +}; + +post '/update' => sub { + my ($self) = @_; + my $params = $self->req->params->to_hash; + + say Dumper($params); + + say Dumper($self->req->uploads); + + $self->render( + data => q{}, + status => 204, + ); +}; + +app->config( + hypnotoad => { + listen => [ $ENV{PICOMON_LISTEN} // 'http://*:8099' ], + pid_file => '/tmp/picomon.pid', + workers => 1, + }, +); + +$ENV{MOJO_MAX_MESSAGE_SIZE} = 1048576; + +app->start; diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep new file mode 100644 index 0000000..8105c9b --- /dev/null +++ b/templates/layouts/default.html.ep @@ -0,0 +1,19 @@ + + + + <%= stash('title') // 'picomon' %> + + +% if ($self->stash('refresh_interval')) { + +% } + + + %= stylesheet '/static/default.css' + + + +%= content + + + diff --git a/templates/main.html.ep b/templates/main.html.ep new file mode 100644 index 0000000..025bb31 --- /dev/null +++ b/templates/main.html.ep @@ -0,0 +1 @@ +

ohai!

-- cgit v1.2.3