use 5.010; use strictures; use Plack::Request qw(); use HTTP::Status qw(HTTP_OK HTTP_METHOD_NOT_ALLOWED); use Local::MyFastaThing qw(process_fasta); sub html_head { return <<''; MyFastaThing Web front-end } sub form { my ($where_am_i) = @_; return <<"";
} sub html_tail { return <<''; } my $app = sub { my ($env) = @_; my $req = Plack::Request->new($env); if ('GET' eq $req->method) { return [HTTP_OK, ['Content-Type' => 'application/xhtml+xml'], [html_head, form($req->uri), html_tail]]; } elsif ('POST' eq $req->method) { return [HTTP_OK, ['Content-Type' => 'application/xhtml+xml'], [html_head, '

', process_fasta($req->upload('fasta') // $req->body_parameters->{sequence}), '

', html_tail]]; } else { return [HTTP_METHOD_NOT_ALLOWED, [],[]]; } };