Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/michal-josef-spacek/plack-app-directory-pyx

Plack PYX directory application.
https://github.com/michal-josef-spacek/plack-app-directory-pyx

plack-app

Last synced: 17 days ago
JSON representation

Plack PYX directory application.

Awesome Lists containing this project

README

        

NAME
Plack::App::Directory::PYX - Plack PYX directory application.

SYNOPSIS
use Plack::App::Directory::PYX;

my $obj = Plack::App::Directory::PYX->new(%parameters);
my $psgi_ar = $obj->serve_path($env, $path_to_file_or_dir);
my $app = $obj->to_app;

METHODS
"new"
my $obj = Plack::App::Directory::PYX->new(%parameters);

Constructor.

Returns instance of object.

* "indent"

Set Tags::Output::* class for output serialization.

Default value is Tags::Output::Raw.

"serve_path"
my $psgi_ar = $obj->serve_path($env, $path_to_file_or_dir);

Process file or directory on disk and serve it to application.

Returns reference to array (PSGI structure).

"to_app"
my $app = $obj->to_app;

Creates Plack application.

Returns Plack::Component object.

EXAMPLE1
use strict;
use warnings;

use File::Temp;
use IO::Barf;
use Plack::App::Directory::PYX;
use Plack::Runner;

# Temporary file with PYX.
my $temp_pyx_file = File::Temp->new->filename;

# PYX file.
my $pyx = <<'END';
(html
(head
(title
-Title
)title
)head
(body
(div
-Hello world
)div
)body
)html
END
barf($temp_pyx_file, $pyx);

# Run application with one PYX file.
my $app = Plack::App::Directory::PYX->new('file' => $temp_pyx_file)->to_app;
Plack::Runner->new->run($app);

# Output:
# HTTP::Server::PSGI: Accepting connections at http://0:5000/

# > curl http://localhost:5000/
# Title

Hello world

EXAMPLE2
use strict;
use warnings;

use File::Temp;
use IO::Barf;
use Plack::App::Directory::PYX;
use Plack::Runner;

# Temporary file with PYX.
my $temp_pyx_file = File::Temp->new->filename;

# PYX file.
my $pyx = <<'END';
(html
(head
(title
-Title
)title
)head
(body
(div
-Hello world
)div
)body
)html
END
barf($temp_pyx_file, $pyx);

# Run application with one PYX file.
my $app = Plack::App::Directory::PYX->new(
'file' => $temp_pyx_file,
'indent' => 'Tags::Output::Indent',
)->to_app;
Plack::Runner->new->run($app);

# Output:
# HTTP::Server::PSGI: Accepting connections at http://0:5000/

# > curl http://localhost:5000/
#
#
#
# Title
#
#
#
#


# Hello world
#

#
#

DEPENDENCIES
English, Error::Pure, Plack::App::Directory, Plack::Util::Accessor,
PYX::SGML::Tags, Tags::Output::Raw, Unicode::UTF8,

REPOSITORY

AUTHOR
Michal Josef Špaček

LICENSE AND COPYRIGHT
© 2016-2022 Michal Josef Špaček

BSD 2-Clause License

VERSION
0.06