diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-02-12 18:29:27 -0800 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-02-12 18:29:27 -0800 |
| commit | ae0e6d987781d2fbf225611e2f8df37380a2bbcd (patch) | |
| tree | 0c19a2a320588c7852bc8cdbff5da40624475b71 /app.pl | |
first
Diffstat (limited to 'app.pl')
| -rw-r--r-- | app.pl | 74 |
1 files changed, 74 insertions, 0 deletions
@@ -0,0 +1,74 @@ +#!/usr/bin/env perl +use Dancer; +use Data::Dumper; +use Data::UUID; + +sub create_uuid{ + my $ug = Data::UUID->new; + my $uuid1 = $ug->create(); + return $uuid1; +# $uuid2 = $ug->create_from_name(<namespace>, <name>); +# +# $res = $ug->compare($uuid1, $uuid2); +# +# $str = $ug->to_string( $uuid ); +# $uuid = $ug->from_string( $str ); +} + +sub cleanup{ + my $tmpdir = shift; + my $clean_exec = system("rm -r ${tmpdir}"); + if( $clean_exec){ + return { error => "Unable to cleanup tempdir" } + } +} + +sub resize_texture { + my $img = shift; + my $tmpdir = shift; + my $tmp_img = $img; + $tmp_img =~ s/\./00./g; + my $exec_im = system ("imagemagick -resize 256x256! $img $tmp_img"); + if ($exec_im){ + return { error => "Unable to resize image" } ; + } + return {}; +} + + +set public => './'; + +get '/download/*.*' => sub { + my ($file, $ext) = splat; + # do something with $file.$ext here +}; + +get qr{/img/([\w\.\-_]+)} => sub { + my ($filename) = splat; + send_file sprintf("/img/%s", $filename); +}; +get qr{/css/([\w\.\-_]+)} => sub { + my ($filename) = splat; + send_file sprintf("/css/%s", $filename); +}; +get qr{/js/([\w\.\-_]+)} => sub { + my ($filename) = splat; + send_file sprintf("/js/%s", $filename); +}; +get '/' => sub { + send_file "index.html"; +}; +get qr{/fonts/([\w\.\-_]+)} => sub { + my ($filename) = splat; + send_file sprintf("/fonts/%s", $filename); +}; + +post '/img/load' => sub { + my $texture = params->{texture}; + my $heightmap = params->{heightmap}; + to_json( { texture => $texture, heightmap => $heightmap } ); + +}; +post 'img/save' => sub { +}; +dance; |
