SlideShare a Scribd company logo
1 of 32
Download to read offline
Mini aplicac˜es web com
            ¸o
Mojolicious::Lite
         Andr´ Santos
              e
       andrefs@cpan.org

       PtPW 2010
         5 de Julho
Disclaimer


   [Web] developer profissional
Disclaimer


   [Web] developer profissional
   Perl::Newbie
Disclaimer


   [Web] developer profissional
   Perl::Newbie

   #{coisas certas} > #{coisas erradas}
Ruby
Ruby



Perl
Ruby
Ruby on Rails
“open source MVC web app framework”

Perl
Ruby
Ruby on Rails
“open source MVC web app framework”

Perl
Catalyst
(outros)
Ruby



Perl
Ruby
Sinatra
pequenas aplicac˜es web
               ¸o

Perl
Ruby
Sinatra
pequenas aplicac˜es web
               ¸o

Perl
Mojolicious::Lite
“micro web framework”
/Mojo.*/

   Mojo
   Mojolicious
   Mojolicious::Lite
/Mojo.*/

   Mojo
   Mojolicious
   Mojolicious::Lite

   criados por Sebastian Riedel
       tamb´m criador de Catalyst
            e
       developer RoR
/Mojo.*/
.---------------------------------------------------------------.
|                             Fun!                              |
’---------------------------------------------------------------’
.---------------------------------------------------------------.
|                                                               |
|                .----------------------------------------------’
|                | .--------------------------------------------.
|   Application | |               Mojolicious::Lite             |
|                | ’--------------------------------------------’
|                | .--------------------------------------------.
|                | |                 Mojolicious                |
’----------------’ ’--------------------------------------------’
.---------------------------------------------------------------.
|                             Mojo                              |
’---------------------------------------------------------------’
.-------. .-----------. .--------. .------------. .-------------.
| CGI | | FastCGI | | PSGI | | HTTP 1.1 | | WebSocket |
’-------’ ’-----------’ ’--------’ ’------------’ ’-------------’
/Mojo.*/

Mojo
  “The box!”
  Encapsula as complexidades de CGI,
  FastCGI, PSGI, HTTP e WebSocket num
  s´ m´todo
   o e
  D´ suporte a frameworks web como
    a
  Mojolicious e Mojolicious::Lite
/Mojo.*/


Mojolicious
   “The web in a box!”
   framework MVC com API OO Perl
   depende apenas de Perl 5.8.1
Mojolicious::Lite

Single file micro web apps framework
 ˜
NAO!
    N˜o apropriado para produc˜o, software
      a                      ¸a
    comercial, ...
Mojolicious::Lite

Single file micro web apps framework
 ˜
NAO!
    N˜o apropriado para produc˜o, software
      a                       ¸a
    comercial, ...
    N˜o apropriado para aplicac˜es complexas
      a                       ¸o
Mojolicious::Lite

Single file micro web apps framework
 ˜
NAO!
    N˜o apropriado para produc˜o, software
      a                       ¸a
    comercial, ...
    N˜o apropriado para aplicac˜es complexas
      a                       ¸o
    N˜o est´ bem documentado (ainda)
      a    a
$ mojolicious generate lite_app
  [exist] ~/folder
  [write] ~/folder/myapp.pl
  [chmod] myapp.pl 744
$ myapp.pl
  ...
  generate         Generate files and directories from templates.
  routes           Show available routes.
  inflate          Inflate embedded files to real files.
  version          Show versions of installed modules.
  daemon_prefork   Start application w/prefork HTTP 1.1 backend.
  fastcgi          Start application with FastCGI backend.
  daemon           Start application with HTTP 1.1 backend.
  cgi              Start application with CGI backend.
  get              Get file from URL.
  psgi             Start application with PSGI backend.
  test             Run unit tests.
$ cat myapp.pl
#!/usr/bin/env perl
use Mojolicious::Lite;

get ’/’ => ’index’;
get ’/:groovy’ => sub {
    my $self = shift;
    $self->render_text($self->param(’groovy’), layout => ’funky’);
};
shagadelic;
__DATA__
@@ index.html.ep
% layout ’funky’;
Yea baby!

@@ layouts/funky.html.ep
<!doctype html><html>
    <head><title>Funky!</title></head>
    <body><%== content %></body>
</html>
$ cat myapp.pl
#!/usr/bin/env perl
use Mojolicious::Lite;

get ’/’ => ’index’;
get ’/:groovy’ => sub {
    my $self = shift;
    $self->render_text($self->param(’groovy’), layout => ’funky’);
};
shagadelic;
__DATA__
@@ index.html.ep
% layout ’funky’;
Yea baby!

@@ layouts/funky.html.ep
<!doctype html><html>
    <head><title>Funky!</title></head>
    <body><%== content %></body>
</html>
$ cat myapp.pl
#!/usr/bin/env perl
use Mojolicious::Lite;

get ’/’ => ’index’;
get ’/:groovy’ => sub {
    my $self = shift;
    $self->render_text($self->param(’groovy’), layout => ’funky’);
};
app->start;
__DATA__
@@ index.html.ep
% layout ’funky’;
Yea baby!

@@ layouts/funky.html.ep
<!doctype html><html>
    <head><title>Funky!</title></head>
    <body><%== content %></body>
</html>
Routes
   get ’/’ => ’index’ # GET ’/’
   get ’/:groovy’ => sub
   # GET ’/anyword’
Routes
   get ’/’ => ’index’ # GET ’/’
   get ’/:groovy’ => sub
   # GET ’/anyword’
   get ’/perl’ # GET ’/perl’
   any [qw/post delete/] ’/bar/:foo’
   # ’ POST or DELETE ’/bar/*’
   any ’/:foo’ => [foo => qr/+/]
                             .
   # ’/2010’
Routes
   get ’/’ => ’index’ # GET ’/’
   get ’/:groovy’ => sub
   # GET ’/anyword’
   get ’/perl’ # GET ’/perl’
   any [qw/post delete/] ’/bar/:foo’
   # ’ POST or DELETE ’/bar/*’
   any ’/:foo’ => [foo => qr/+/]
                             .
   # ’/2010’
   get ’/number/:num’ => {num => 42}
   get ’/path/(*everything)
Templates



   Sistema de templates pr´prio; ou
                          o
   Template Toolkit, ...
Exemplos
http://d.hatena.ne.jp/yukikimoto/20100220/1266588242



      Short message BSS (150 loc)
      Image BSS (156 loc)
      Simple search (106 loc)
      Simple real time clock (133 loc)
      Simple real time chat (207 loc)
$ myapp.pl inflate


 [mkdir]   ~/folder/templates/layouts
 [write]   ~/folder/templates/layouts/funky.html.
 [exist]   ~/folder/templates
 [write]   ~/folder/templates/index.html.ep
Trabalho semelhante
   Sinatra on Perl,
   github.com/jtarchie/
   sinatra-on-perl
   Schenker,
   github.com/spiritloose/Schenker
   Dancer,
   perldancer.org
Trabalho semelhante
   Sinatra on Perl,
   github.com/jtarchie/
   sinatra-on-perl
   Schenker,
   github.com/spiritloose/Schenker
   Dancer,
   perldancer.org

Mojolicious::Lite vs Dancer
http://use.perl.org/~Alias/journal/
Questions




            o/

More Related Content

What's hot

Lightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientLightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientAdam Wiggins
 
Quick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with HerokuQuick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with HerokuDaniel Pritchett
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglHtml5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglKilian Valkhof
 
Real-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.ioReal-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.ioRick Copeland
 
Rush, a shell that will yield to you
Rush, a shell that will yield to youRush, a shell that will yield to you
Rush, a shell that will yield to youguestdd9d06
 
mruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしmruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしHiroshi SHIBATA
 
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)Brian Sam-Bodden
 
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationBasicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationDinesh Manajipet
 
Cooking Up Drama - ChefConf 2015
Cooking Up Drama - ChefConf 2015 Cooking Up Drama - ChefConf 2015
Cooking Up Drama - ChefConf 2015 Chef
 
Implementing pattern-matching in JavaScript (short version)
Implementing pattern-matching in JavaScript (short version)Implementing pattern-matching in JavaScript (short version)
Implementing pattern-matching in JavaScript (short version)François-Guillaume Ribreau
 
Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話dcubeio
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101hendrikvb
 
HTTPS + Let's Encrypt
HTTPS + Let's EncryptHTTPS + Let's Encrypt
HTTPS + Let's EncryptWalter Ebert
 

What's hot (19)

Lightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientLightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClient
 
Triple Blitz Strike
Triple Blitz StrikeTriple Blitz Strike
Triple Blitz Strike
 
Quick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with HerokuQuick and Dirty Python Deployments with Heroku
Quick and Dirty Python Deployments with Heroku
 
Start using vagrant now!
Start using vagrant now!Start using vagrant now!
Start using vagrant now!
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglHtml5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webgl
 
Real-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.ioReal-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.io
 
Qless
QlessQless
Qless
 
Rush, a shell that will yield to you
Rush, a shell that will yield to youRush, a shell that will yield to you
Rush, a shell that will yield to you
 
mruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしmruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなし
 
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)
 
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationBasicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt application
 
Cooking Up Drama
Cooking Up DramaCooking Up Drama
Cooking Up Drama
 
Cooking Up Drama - ChefConf 2015
Cooking Up Drama - ChefConf 2015 Cooking Up Drama - ChefConf 2015
Cooking Up Drama - ChefConf 2015
 
Implementing pattern-matching in JavaScript (short version)
Implementing pattern-matching in JavaScript (short version)Implementing pattern-matching in JavaScript (short version)
Implementing pattern-matching in JavaScript (short version)
 
Perl dancer
Perl dancerPerl dancer
Perl dancer
 
About Data::ObjectDriver
About Data::ObjectDriverAbout Data::ObjectDriver
About Data::ObjectDriver
 
Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話Go初心者がGoでコマンドラインツールの作成に挑戦した話
Go初心者がGoでコマンドラインツールの作成に挑戦した話
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
 
HTTPS + Let's Encrypt
HTTPS + Let's EncryptHTTPS + Let's Encrypt
HTTPS + Let's Encrypt
 

Viewers also liked

Cleaning plain text books with Text::Perfide::BookCleaner
Cleaning plain text books with Text::Perfide::BookCleanerCleaning plain text books with Text::Perfide::BookCleaner
Cleaning plain text books with Text::Perfide::BookCleanerandrefsantos
 
Professional Certifications
Professional CertificationsProfessional Certifications
Professional Certificationseeakin79
 
Student leadership in conduct symposiumonline
Student leadership in conduct   symposiumonlineStudent leadership in conduct   symposiumonline
Student leadership in conduct symposiumonlineTEDx Adventure Catalyst
 
Maestri necunoscuti j (lh)
Maestri necunoscuti j (lh)Maestri necunoscuti j (lh)
Maestri necunoscuti j (lh)filipj2000
 
Colchon flotable a luz solar
Colchon flotable a luz solarColchon flotable a luz solar
Colchon flotable a luz solarLili Krrillo
 
Examples of our website work
Examples of our website workExamples of our website work
Examples of our website workJeremy Dawes
 
乘科技風潮 學術生涯規劃
乘科技風潮 學術生涯規劃乘科技風潮 學術生涯規劃
乘科技風潮 學術生涯規劃tpliang
 
242260 rosette1945
242260 rosette1945242260 rosette1945
242260 rosette1945filipj2000
 
Pps delz@-budapest - i - left bank-the historic part and more
Pps delz@-budapest - i - left bank-the historic part and morePps delz@-budapest - i - left bank-the historic part and more
Pps delz@-budapest - i - left bank-the historic part and morefilipj2000
 
The Worry Line Incision
The Worry Line IncisionThe Worry Line Incision
The Worry Line Incisionmoosews
 
Set a featured image of a page in WordPress
Set a featured image of a page in WordPressSet a featured image of a page in WordPress
Set a featured image of a page in WordPressJeremy Dawes
 
Thunderbird imap settings
Thunderbird imap settingsThunderbird imap settings
Thunderbird imap settingsJeremy Dawes
 

Viewers also liked (19)

Cleaning plain text books with Text::Perfide::BookCleaner
Cleaning plain text books with Text::Perfide::BookCleanerCleaning plain text books with Text::Perfide::BookCleaner
Cleaning plain text books with Text::Perfide::BookCleaner
 
Professional Certifications
Professional CertificationsProfessional Certifications
Professional Certifications
 
Student leadership in conduct symposiumonline
Student leadership in conduct   symposiumonlineStudent leadership in conduct   symposiumonline
Student leadership in conduct symposiumonline
 
Universal Design August Workshop
Universal Design August Workshop Universal Design August Workshop
Universal Design August Workshop
 
Chine
ChineChine
Chine
 
Maestri necunoscuti j (lh)
Maestri necunoscuti j (lh)Maestri necunoscuti j (lh)
Maestri necunoscuti j (lh)
 
Final mh 101 for owls 2015(1)
Final mh 101 for owls 2015(1)Final mh 101 for owls 2015(1)
Final mh 101 for owls 2015(1)
 
Colchon flotable a luz solar
Colchon flotable a luz solarColchon flotable a luz solar
Colchon flotable a luz solar
 
Examples of our website work
Examples of our website workExamples of our website work
Examples of our website work
 
El proceso
El procesoEl proceso
El proceso
 
乘科技風潮 學術生涯規劃
乘科技風潮 學術生涯規劃乘科技風潮 學術生涯規劃
乘科技風潮 學術生涯規劃
 
242260 rosette1945
242260 rosette1945242260 rosette1945
242260 rosette1945
 
Pps delz@-budapest - i - left bank-the historic part and more
Pps delz@-budapest - i - left bank-the historic part and morePps delz@-budapest - i - left bank-the historic part and more
Pps delz@-budapest - i - left bank-the historic part and more
 
La Excepción
La ExcepciónLa Excepción
La Excepción
 
The Worry Line Incision
The Worry Line IncisionThe Worry Line Incision
The Worry Line Incision
 
Dr Natalia Haraszkiewicz-Birkemeier_KWF Kankerbestrijding
Dr Natalia Haraszkiewicz-Birkemeier_KWF KankerbestrijdingDr Natalia Haraszkiewicz-Birkemeier_KWF Kankerbestrijding
Dr Natalia Haraszkiewicz-Birkemeier_KWF Kankerbestrijding
 
Pdf 1
Pdf 1Pdf 1
Pdf 1
 
Set a featured image of a page in WordPress
Set a featured image of a page in WordPressSet a featured image of a page in WordPress
Set a featured image of a page in WordPress
 
Thunderbird imap settings
Thunderbird imap settingsThunderbird imap settings
Thunderbird imap settings
 

Similar to Create Mini Web Apps with Mojolicious::Lite

Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hopeMarcus Ramberg
 
Baremetal deployment scale
Baremetal deployment scaleBaremetal deployment scale
Baremetal deployment scalebaremetal
 
Caching with Varnish
Caching with VarnishCaching with Varnish
Caching with Varnishschoefmax
 
Dexterity in 15 minutes or less
Dexterity in 15 minutes or lessDexterity in 15 minutes or less
Dexterity in 15 minutes or lessrijk.stofberg
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Toolsrjsmelo
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsDylan Jay
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Herokuronnywang_tw
 
Baremetal deployment
Baremetal deploymentBaremetal deployment
Baremetal deploymentbaremetal
 
Scripting for infosecs
Scripting for infosecsScripting for infosecs
Scripting for infosecsnancysuemartin
 
How to test code with mruby
How to test code with mrubyHow to test code with mruby
How to test code with mrubyHiroshi SHIBATA
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!cloudbring
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)Soshi Nemoto
 
Create your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and PackerCreate your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and Packerfrastel
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpMatthew Davis
 

Similar to Create Mini Web Apps with Mojolicious::Lite (20)

Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Baremetal deployment scale
Baremetal deployment scaleBaremetal deployment scale
Baremetal deployment scale
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
Caching with Varnish
Caching with VarnishCaching with Varnish
Caching with Varnish
 
Dexterity in 15 minutes or less
Dexterity in 15 minutes or lessDexterity in 15 minutes or less
Dexterity in 15 minutes or less
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Tools
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web apps
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Baremetal deployment
Baremetal deploymentBaremetal deployment
Baremetal deployment
 
PSGI/Plack OSDC.TW
PSGI/Plack OSDC.TWPSGI/Plack OSDC.TW
PSGI/Plack OSDC.TW
 
Scripting for infosecs
Scripting for infosecsScripting for infosecs
Scripting for infosecs
 
How to test code with mruby
How to test code with mrubyHow to test code with mruby
How to test code with mruby
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
 
Create your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and PackerCreate your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and Packer
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
 

More from andrefsantos

Building your own CPAN with Pinto
Building your own CPAN with PintoBuilding your own CPAN with Pinto
Building your own CPAN with Pintoandrefsantos
 
Identifying similar text documents
Identifying similar text documentsIdentifying similar text documents
Identifying similar text documentsandrefsantos
 
Poster - Bigorna, a toolkit for orthography migration challenges
Poster - Bigorna, a toolkit for orthography migration challengesPoster - Bigorna, a toolkit for orthography migration challenges
Poster - Bigorna, a toolkit for orthography migration challengesandrefsantos
 
Text::Perfide::BookCleaner, a Perl module to clean and normalize plain text b...
Text::Perfide::BookCleaner, a Perl module to clean and normalize plain text b...Text::Perfide::BookCleaner, a Perl module to clean and normalize plain text b...
Text::Perfide::BookCleaner, a Perl module to clean and normalize plain text b...andrefsantos
 
A survey on parallel corpora alignment
A survey on parallel corpora alignment A survey on parallel corpora alignment
A survey on parallel corpora alignment andrefsantos
 
Detecção e Correcção Parcial de Problemas na Conversão de Formatos
Detecção e Correcção Parcial de Problemas na Conversão de FormatosDetecção e Correcção Parcial de Problemas na Conversão de Formatos
Detecção e Correcção Parcial de Problemas na Conversão de Formatosandrefsantos
 
Bigorna - a toolkit for orthography migration challenges
Bigorna - a toolkit for orthography migration challengesBigorna - a toolkit for orthography migration challenges
Bigorna - a toolkit for orthography migration challengesandrefsantos
 

More from andrefsantos (10)

Elasto Mania
Elasto ManiaElasto Mania
Elasto Mania
 
Building your own CPAN with Pinto
Building your own CPAN with PintoBuilding your own CPAN with Pinto
Building your own CPAN with Pinto
 
Slides
SlidesSlides
Slides
 
Identifying similar text documents
Identifying similar text documentsIdentifying similar text documents
Identifying similar text documents
 
Poster - Bigorna, a toolkit for orthography migration challenges
Poster - Bigorna, a toolkit for orthography migration challengesPoster - Bigorna, a toolkit for orthography migration challenges
Poster - Bigorna, a toolkit for orthography migration challenges
 
Text::Perfide::BookCleaner, a Perl module to clean and normalize plain text b...
Text::Perfide::BookCleaner, a Perl module to clean and normalize plain text b...Text::Perfide::BookCleaner, a Perl module to clean and normalize plain text b...
Text::Perfide::BookCleaner, a Perl module to clean and normalize plain text b...
 
A survey on parallel corpora alignment
A survey on parallel corpora alignment A survey on parallel corpora alignment
A survey on parallel corpora alignment
 
Detecção e Correcção Parcial de Problemas na Conversão de Formatos
Detecção e Correcção Parcial de Problemas na Conversão de FormatosDetecção e Correcção Parcial de Problemas na Conversão de Formatos
Detecção e Correcção Parcial de Problemas na Conversão de Formatos
 
Bigorna - a toolkit for orthography migration challenges
Bigorna - a toolkit for orthography migration challengesBigorna - a toolkit for orthography migration challenges
Bigorna - a toolkit for orthography migration challenges
 
Bigorna
BigornaBigorna
Bigorna
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

Create Mini Web Apps with Mojolicious::Lite

  • 1. Mini aplicac˜es web com ¸o Mojolicious::Lite Andr´ Santos e andrefs@cpan.org PtPW 2010 5 de Julho
  • 2. Disclaimer [Web] developer profissional
  • 3. Disclaimer [Web] developer profissional Perl::Newbie
  • 4. Disclaimer [Web] developer profissional Perl::Newbie #{coisas certas} > #{coisas erradas}
  • 7. Ruby Ruby on Rails “open source MVC web app framework” Perl
  • 8. Ruby Ruby on Rails “open source MVC web app framework” Perl Catalyst (outros)
  • 11. Ruby Sinatra pequenas aplicac˜es web ¸o Perl Mojolicious::Lite “micro web framework”
  • 12. /Mojo.*/ Mojo Mojolicious Mojolicious::Lite
  • 13. /Mojo.*/ Mojo Mojolicious Mojolicious::Lite criados por Sebastian Riedel tamb´m criador de Catalyst e developer RoR
  • 14. /Mojo.*/ .---------------------------------------------------------------. | Fun! | ’---------------------------------------------------------------’ .---------------------------------------------------------------. | | | .----------------------------------------------’ | | .--------------------------------------------. | Application | | Mojolicious::Lite | | | ’--------------------------------------------’ | | .--------------------------------------------. | | | Mojolicious | ’----------------’ ’--------------------------------------------’ .---------------------------------------------------------------. | Mojo | ’---------------------------------------------------------------’ .-------. .-----------. .--------. .------------. .-------------. | CGI | | FastCGI | | PSGI | | HTTP 1.1 | | WebSocket | ’-------’ ’-----------’ ’--------’ ’------------’ ’-------------’
  • 15. /Mojo.*/ Mojo “The box!” Encapsula as complexidades de CGI, FastCGI, PSGI, HTTP e WebSocket num s´ m´todo o e D´ suporte a frameworks web como a Mojolicious e Mojolicious::Lite
  • 16. /Mojo.*/ Mojolicious “The web in a box!” framework MVC com API OO Perl depende apenas de Perl 5.8.1
  • 17. Mojolicious::Lite Single file micro web apps framework ˜ NAO! N˜o apropriado para produc˜o, software a ¸a comercial, ...
  • 18. Mojolicious::Lite Single file micro web apps framework ˜ NAO! N˜o apropriado para produc˜o, software a ¸a comercial, ... N˜o apropriado para aplicac˜es complexas a ¸o
  • 19. Mojolicious::Lite Single file micro web apps framework ˜ NAO! N˜o apropriado para produc˜o, software a ¸a comercial, ... N˜o apropriado para aplicac˜es complexas a ¸o N˜o est´ bem documentado (ainda) a a
  • 20. $ mojolicious generate lite_app [exist] ~/folder [write] ~/folder/myapp.pl [chmod] myapp.pl 744 $ myapp.pl ... generate Generate files and directories from templates. routes Show available routes. inflate Inflate embedded files to real files. version Show versions of installed modules. daemon_prefork Start application w/prefork HTTP 1.1 backend. fastcgi Start application with FastCGI backend. daemon Start application with HTTP 1.1 backend. cgi Start application with CGI backend. get Get file from URL. psgi Start application with PSGI backend. test Run unit tests.
  • 21. $ cat myapp.pl #!/usr/bin/env perl use Mojolicious::Lite; get ’/’ => ’index’; get ’/:groovy’ => sub { my $self = shift; $self->render_text($self->param(’groovy’), layout => ’funky’); }; shagadelic; __DATA__ @@ index.html.ep % layout ’funky’; Yea baby! @@ layouts/funky.html.ep <!doctype html><html> <head><title>Funky!</title></head> <body><%== content %></body> </html>
  • 22. $ cat myapp.pl #!/usr/bin/env perl use Mojolicious::Lite; get ’/’ => ’index’; get ’/:groovy’ => sub { my $self = shift; $self->render_text($self->param(’groovy’), layout => ’funky’); }; shagadelic; __DATA__ @@ index.html.ep % layout ’funky’; Yea baby! @@ layouts/funky.html.ep <!doctype html><html> <head><title>Funky!</title></head> <body><%== content %></body> </html>
  • 23. $ cat myapp.pl #!/usr/bin/env perl use Mojolicious::Lite; get ’/’ => ’index’; get ’/:groovy’ => sub { my $self = shift; $self->render_text($self->param(’groovy’), layout => ’funky’); }; app->start; __DATA__ @@ index.html.ep % layout ’funky’; Yea baby! @@ layouts/funky.html.ep <!doctype html><html> <head><title>Funky!</title></head> <body><%== content %></body> </html>
  • 24. Routes get ’/’ => ’index’ # GET ’/’ get ’/:groovy’ => sub # GET ’/anyword’
  • 25. Routes get ’/’ => ’index’ # GET ’/’ get ’/:groovy’ => sub # GET ’/anyword’ get ’/perl’ # GET ’/perl’ any [qw/post delete/] ’/bar/:foo’ # ’ POST or DELETE ’/bar/*’ any ’/:foo’ => [foo => qr/+/] . # ’/2010’
  • 26. Routes get ’/’ => ’index’ # GET ’/’ get ’/:groovy’ => sub # GET ’/anyword’ get ’/perl’ # GET ’/perl’ any [qw/post delete/] ’/bar/:foo’ # ’ POST or DELETE ’/bar/*’ any ’/:foo’ => [foo => qr/+/] . # ’/2010’ get ’/number/:num’ => {num => 42} get ’/path/(*everything)
  • 27. Templates Sistema de templates pr´prio; ou o Template Toolkit, ...
  • 28. Exemplos http://d.hatena.ne.jp/yukikimoto/20100220/1266588242 Short message BSS (150 loc) Image BSS (156 loc) Simple search (106 loc) Simple real time clock (133 loc) Simple real time chat (207 loc)
  • 29. $ myapp.pl inflate [mkdir] ~/folder/templates/layouts [write] ~/folder/templates/layouts/funky.html. [exist] ~/folder/templates [write] ~/folder/templates/index.html.ep
  • 30. Trabalho semelhante Sinatra on Perl, github.com/jtarchie/ sinatra-on-perl Schenker, github.com/spiritloose/Schenker Dancer, perldancer.org
  • 31. Trabalho semelhante Sinatra on Perl, github.com/jtarchie/ sinatra-on-perl Schenker, github.com/spiritloose/Schenker Dancer, perldancer.org Mojolicious::Lite vs Dancer http://use.perl.org/~Alias/journal/
  • 32. Questions o/