Added success calls to file upload

This commit is contained in:
piratefinn 2016-09-05 17:52:45 +01:00
parent 0311ad916c
commit 3eb310fc26

View file

@ -26,11 +26,11 @@ any '/' => sub {
post '/upload' => sub { post '/upload' => sub {
my $self = shift; my $self = shift;
# Fetch parameters to write to DB # Fetch parameters to write to DB
# my $key = $self->param('key'); my $key = $self->param('key');
# This will include an if function to see if key matches # This will include an if function to see if key matches
# unless ($key eq $config->{key}) { unless ($key eq $config->{key}) {
# return $self->render( json => { success => Mojo::JSON->false }, status => 403 ); return $self->render( json => { success => Mojo::JSON->false }, status => 403 );
# } }
my $username = $self->param('username'); my $username = $self->param('username');
my $company = $self->param('company'); my $company = $self->param('company');
my $currency = $self->param('currency'); my $currency = $self->param('currency');
@ -53,6 +53,7 @@ post '/upload' => sub {
# send data to foodloop db # send data to foodloop db
my $insert = $self->db->prepare('INSERT INTO foodloop (username, company, currency, filename) VALUES (?,?,?,?)'); my $insert = $self->db->prepare('INSERT INTO foodloop (username, company, currency, filename) VALUES (?,?,?,?)');
$insert->execute($username, $company, $currency, $filename); $insert->execute($username, $company, $currency, $filename);
$self->render( json => { success => Mojo::JSON->true } );
$self->render(text => 'It did not kaboom!'); $self->render(text => 'It did not kaboom!');
}; };