Skip to content

Instantly share code, notes, and snippets.

@alranel
Created June 27, 2012 17:03
Show Gist options
  • Save alranel/3005407 to your computer and use it in GitHub Desktop.
Save alranel/3005407 to your computer and use it in GitHub Desktop.
A webserver to process files through Slic3r
#!/usr/bin/perl
use Dancer;
use File::Slurp qw(read_file);
use File::Temp qw(tempfile);
post '/slice' => sub {
if (my $upload = upload 'stl') {
my (undef, $tmp) = tempfile();
system qw(/path/to/slic3r.pl --load /path/to/config.ini), $upload->tempname, qw(-o), $tmp
and return status 500;
content_type 'text/plain';
return read_file($tmp);
}
};
dance;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment