SlideShare a Scribd company logo
Submit Search
Upload
Writing webapps with Perl Dancer
Report
Alexis Sukrieh
Free Software developer (Backup Manager, Perl) at Yoolink
Follow
•
19 likes
•
29,441 views
1
of
101
Writing webapps with Perl Dancer
•
19 likes
•
29,441 views
Download Now
Download to read offline
Report
Technology
Dancer is a micro framework for Perl, this presentation describes it and show how to use it.
Read more
Alexis Sukrieh
Free Software developer (Backup Manager, Perl) at Yoolink
Follow
Recommended
Perl Dancer for Python programmers
xSawyer
16.3K views
•
31 slides
Perl Dancer, FPW 2010
Alexis Sukrieh
17.1K views
•
114 slides
PerlDancer for Perlers (FOSDEM 2011)
xSawyer
4.1K views
•
36 slides
An introduction to Rex - FLOSS UK DevOps York 2015
Andy Beverley
4K views
•
29 slides
Dancing Tutorial
Alberto Simões
14.3K views
•
44 slides
Dancer's Ecosystem
Alexis Sukrieh
1.2K views
•
67 slides
More Related Content
What's hot
Lightweight Webservices with Sinatra and RestClient
Adam Wiggins
24.1K views
•
47 slides
Intro to Rails
epiineg1
323 views
•
28 slides
JSON and the APInauts
Wynn Netherland
5.1K views
•
84 slides
Mojolicious
Marcos Rebelo
5.4K views
•
44 slides
Using Sinatra to Build REST APIs in Ruby
LaunchAny
9.5K views
•
53 slides
Go初心者がGoでコマンドラインツールの作成に挑戦した話
dcubeio
6.4K views
•
66 slides
What's hot
(20)
Lightweight Webservices with Sinatra and RestClient
Adam Wiggins
•
24.1K views
Intro to Rails
epiineg1
•
323 views
JSON and the APInauts
Wynn Netherland
•
5.1K views
Mojolicious
Marcos Rebelo
•
5.4K views
Using Sinatra to Build REST APIs in Ruby
LaunchAny
•
9.5K views
Go初心者がGoでコマンドラインツールの作成に挑戦した話
dcubeio
•
6.4K views
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
Puppet
•
1.7K views
Magical WordPress Development with Vagrant
Chris Olbekson
•
3.4K views
Web development automatisation for fun and profit (Artem Daniliants)
LumoSpark
•
350 views
Your own (little) gem: building an online business with Ruby
Lindsay Holmwood
•
1.1K views
Babushka
Richard McGain
•
542 views
Ansible leveraging 2.0
bcoca
•
1.3K views
V2 and beyond
jimi-c
•
13.9K views
Task 1
EdiPHP
•
403 views
AnsibleFest 2014 - Role Tips and Tricks
jimi-c
•
12.7K views
PerlでWeb API入門
Yusuke Wada
•
7K views
Writing Friendly libraries for CodeIgniter
CodeIgniter Conference
•
1.3K views
Hubot: a look inside our robot friend
ajacksified
•
3.5K views
More tips n tricks
bcoca
•
5.3K views
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Habeeb Rahman
•
3.3K views
Similar to Writing webapps with Perl Dancer
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
Atlassian
462 views
•
33 slides
Summit2011 satellites-robinf-20110605
Robin Fernandes
683 views
•
33 slides
Writing Pluggable Software
Tatsuhiko Miyagawa
3.9K views
•
112 slides
Modern Perl
Dave Cross
6.6K views
•
107 slides
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Jon Peck
2.2K views
•
28 slides
Maintaining your own branch of Drupal core
drumm
1K views
•
29 slides
Similar to Writing webapps with Perl Dancer
(20)
Satellite Apps around the Cloud: Integrating your infrastructure with JIRA St...
Atlassian
•
462 views
Summit2011 satellites-robinf-20110605
Robin Fernandes
•
683 views
Writing Pluggable Software
Tatsuhiko Miyagawa
•
3.9K views
Modern Perl
Dave Cross
•
6.6K views
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Jon Peck
•
2.2K views
Maintaining your own branch of Drupal core
drumm
•
1K views
Pyramid Lighter/Faster/Better web apps
Dylan Jay
•
10.6K views
Ratpack - Classy and Compact Groovy Web Apps
James Williams
•
4.2K views
PSGI and Plack from first principles
Perl Careers
•
2K views
Mojolicious on Steroids
Tudor Constantin
•
3.8K views
Building your first Node app with Connect & Express
Christian Joudrey
•
21.2K views
Rush, a shell that will yield to you
guestdd9d06
•
744 views
Extending Zend Framework
PHPBelgium
•
1.7K views
A Quick Introduction to Sinatra
guestbe060
•
1.8K views
A Quick Introduction to Sinatra
Nick Plante
•
340 views
Multi tenant CMSes using php
kae-verens
•
3.2K views
Going crazy with Node.JS and CakePHP
Mariano Iglesias
•
13.8K views
Think Generic - Add API's To Your Custom Modules
Jens Sørensen
•
412 views
Render API - Pavel Makhrinsky
DrupalCampDN
•
524 views
Evolving Software with Moose
Dave Cross
•
2K views
Recently uploaded
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10
42 views
•
20 slides
AMD: 4th Generation EPYC CXL Demo
CXL Forum
117 views
•
6 slides
Business Analyst Series 2023 - Week 2 Session 3
DianaGray10
307 views
•
22 slides
ChatGPT and AI for Web Developers
Maximiliano Firtman
152 views
•
82 slides
"Fast Start to Building on AWS", Igor Ivaniuk
Fwdays
31 views
•
76 slides
Green Leaf Consulting: Capabilities Deck
GreenLeafConsulting
170 views
•
18 slides
Recently uploaded
(20)
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10
•
42 views
AMD: 4th Generation EPYC CXL Demo
CXL Forum
•
117 views
Business Analyst Series 2023 - Week 2 Session 3
DianaGray10
•
307 views
ChatGPT and AI for Web Developers
Maximiliano Firtman
•
152 views
"Fast Start to Building on AWS", Igor Ivaniuk
Fwdays
•
31 views
Green Leaf Consulting: Capabilities Deck
GreenLeafConsulting
•
170 views
PyCon ID 2023 - Ridwan Fadjar Septian.pdf
Ridwan Fadjar
•
163 views
Samsung: CMM-H Tiered Memory Solution with Built-in DRAM
CXL Forum
•
96 views
Webinar : Competing for tomorrow’s leaders – How MENA insurers can win the wa...
The Digital Insurer
•
24 views
JCon Live 2023 - Lice coding some integration problems
Bernd Ruecker
•
61 views
[2023] Putting the R! in R&D.pdf
Eleanor McHugh
•
34 views
Throughput
Moisés Armani Ramírez
•
28 views
Astera Labs: Intelligent Connectivity for Cloud and AI Infrastructure
CXL Forum
•
118 views
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
Prity Khastgir IPR Strategic India Patent Attorney Amplify Innovation
•
23 views
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur
Fwdays
•
35 views
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi
•
77 views
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy
Fwdays
•
35 views
GigaIO: The March of Composability Onward to Memory with CXL
CXL Forum
•
118 views
"How we switched to Kanban and how it integrates with product planning", Vady...
Fwdays
•
59 views
.conf Go 2023 - Raiffeisen Bank International
Splunk
•
170 views
Writing webapps with Perl Dancer
1.
Dancer A
micro framework for writing web applications Alexis Sukrieh OSDCfr 2009
2.
Alexis Sukrieh http://sukria.net
http://twitter.com/sukria http://search.cpan.org/~sukria/
3.
Dancer http://dancer.sukria.net $
sudo cpan Dancer http://github.com/sukria/Dancer
4.
Description Syntax Application
Tree Environments Deployment
5.
webapp framework
for Perl
6.
Again, another one
!!?
7.
YES.
8.
Why ?
9.
Web Development in
Perl can be :
10.
CGI.pm : fat
webapp junkfood
11.
Catalyst : it's
huge, but, it's huge.
12.
Plenty of other
frameworks alike
13.
Ruby introduced something
else
14.
A new approach
to webapp development
15.
Perl needed the
same
16.
definetly
17.
Kindly stolen from
Ruby
18.
So, Dancer is
a framework ...
19.
a micro
framework
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
package
MyApp ; use Dancer; get '/' => sub { 'Hello OSDCfr 2009!' }; dance;
30.
A dancer script
is a webserver
31.
$ ./myApp.pl >>
Listening on 127.0.0.1:3000 == Entering the development dance floor ...
32.
Working webapp ready
to be hacked
33.
» happiness :
he can WSFC now
34.
Description Syntax Application
Tree Environments Deployment
35.
A Dancer app
is defined with route handlers
36.
a route handler
is basically a sub
37.
bound to an
HTTP method (typically ' get ' or ' post ')
38.
with a path
pattern
39.
/foo /bar/:var /baz/*
r('/stuff/([a-z0-9]+)/')
40.
Static pattern (path)
/ /foo /bar/baz
41.
pattern with named
tokens /hello/:buddy my $name = params->{buddy}
42.
pattern with anonymous
tokens /show/*.* my ($file, $ext) = splat;
43.
pseudo-regexp-defined patterns r('/post/([a-z0-9]+)')
my ($post) = splat; # $1
44.
processing a request
= finding a matching route handler
45.
404 No matching
route handler » no joy
46.
Route handler found
» Joy
47.
When found,
a route handler is executed
48.
it can alter
the response headers get '/' => sub { content_type 'text/plain'; return 'this is plain text' };
49.
pass to the
next matching handler get '/lazy' => sub { pass and return false; };
50.
serve a static
file get '/dowload/:file' => sub { my $file = params->{file}; if (! -f $file) { pass and return false; } send_file $file; };
51.
throw an error
get '/forbidden' => sub { send_error 'Nope'; };
52.
redirect to somewhere
else get '/forbidden' => sub { redirect '/better/place' };
53.
and of course,
render a content get '/showme' => sub { template 'showme', { var => 'foo'}; };
54.
return value
= content to render
55.
logging ?
56.
get '/' =>
sub { # ... debug 'here it is'; }; » logs/development.log
57.
pre-processing ?
58.
before sub {
do_some_init_stuff(); params->{foo} = 'beenthere'; };
59.
static file serving
?
60.
existing file
in $appdir/public = file served , no handler needed
61.
Description Syntax Application
Tree Environments Deployment
62.
app.pl
63.
app.pl views/ index.tt
64.
app.pl views/ index.tt
layouts/ main.tt
65.
app.pl views/ index.tt
layouts/ main.tt config.yml
66.
app.pl views/ index.tt
layouts/ main.tt config.yml environments/ development.yml production.yml
67.
app.pl views/ index.tt
layouts/ main.tt config.yml environments/ development.yml production.yml public/
68.
bootstraping ?
69.
$ dancer -a
MyApp
70.
+ MyApp +
MyApp/views + MyApp/views/index.tt + MyApp/views/layouts + MyApp/views/layouts/main.tt + MyApp/environments + MyApp/environments/development.yml + MyApp/environments/production.yml + MyApp/config.yml + MyApp/app.psgi + MyApp/MyApp.pm + MyApp/MyApp.pl + MyApp/public + MyApp/public/css + MyApp/public/css/style.css + MyApp/public/css/error.css + MyApp/public/images + MyApp/public/404.html + MyApp/public/500.html
71.
» Working webapp,
pre-configured, pre-designed and waiting for your hacks
72.
Description Syntax Application
Tree Environments Deployment
73.
settings : customizing
the app
74.
settings in the
app code
75.
use Dancer; set
layout => 'application' set foo => 42; set content_type =>'text/plain';
76.
handy at first,
but dirty
77.
YAML config files:
goodness
78.
# config.yml layout:
'application' foo: 42 content_type: 'text/plain'
79.
config.yml = global
configuration
80.
environments/foo.yml « foo » configuration
81.
$ dancer -e
foo runs the app in « foo » environment
82.
development.yml warnings: 1
show_errors: 1 ...
83.
production.yml warnings: 0
show_errors: 0 ...
84.
show_errors: 1
85.
show_errors: 0
86.
Description Syntax Application
Tree Environments Deployment
87.
For production needs,
use PSGI/Plack
88.
Plack is to
Perl : what Rack is to Ruby what WSGI is to Python
89.
universal server
<-> application gateway
90.
PSGI/Plack miyagawa http://plackperl.org
91.
Dancer supports Plack
since 0.9904
92.
app.psgi tells Plack
how to dance
93.
use CGI::PSGI; use
MyApp; my $handler = sub { my $env = shift; my $cgi = CGI::PSGI->new($env); Dancer->dance($cgi); };
94.
The app is
now PSGI/Plack aware
95.
$ plackup -a
app.psgi &
96.
Webservers have PSGI
adapters
97.
Apache (mod_psgi) nginx
Perlbal HTTP::Server::Fast Plack (standalone)
98.
Conf example with
Apache <Location /> SetHandler perl-script PerlHandler Plack::Server::Apache2 PerlSetVar psgi_app /path/app.psgi </Location>
99.
Works pretty well
100.
enjoy web development
with Perl
101.
DANCE!