Lets create a website!
Lets find an interesting module●   Go to CPAN●   Search for something funny in Text::●   We found Text::UpsideDown●   It t...
Text::UpsideDown    use Text::UpsideDown;    my $text   = “Hello world!”;    my $updown = upside_down($text);●   Okay, tha...
Installing Dancer
Installing Dancer
Creating the skeleton●   Dancer installs an app called “dancer”●   Run it to create a directory structure●   Pretty defaul...
Adding code●   Edit main path in lib/UpsideDown.pm    # default path    get / => sub {      # code to run when someone goe...
Adding code●   Suppose we get user text with a parameter●   Use Dancers “params” to reach it●   If its called “text”, all ...
What do we have so far?●   Someone reaches main page●   We get text and turn it upside down    use Text::UpsideDown;    ge...
Rendering it●   Render template “view/index.tt”●   Send it the original text and the upside down    template index => {   ...
Putting it all togetheruse Text::UpsideDown;get / => sub {  my $text = params­>{text};  my $updown = upside_down($text);  ...
Now the template●   Edit index.tt file●   Add a form to send text●   Add a text input to write the text●   Display the ups...
Creating a form<form method=”post”>  <!-- stuff goes here --></form>
Adding a text input box<form method=”post”><input type=”text” name=”text”   value=”<% text | html %>” /></form>
Adding upside down text<form method=”post”><input type=”text” name=”text”   value=”<% text | html %>” /><code><% upsidedow...
Add button to submit form<form method=”post”><input type=”text” name=”text”   value=”<% text | html %>” /><code><% upsided...
Hit it!
upsidedown.casa.darkpan.com
Dancer available @ http://perldancer.org                  Credit:             Marco Fontani          (http://darkpan.com)
Your first website in under a minute with Dancer
Upcoming SlideShare
Loading in...5
×

Your first website in under a minute with Dancer

3,359

Published on

Learn how to write your first website using Perl and Dancer in under a minute!

This is a lightning talk given at a Tel Aviv Perl Mongers (TA.pm) group meeting.

Published in: Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,359
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
17
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Your first website in under a minute with Dancer

  1. 1. Lets create a website!
  2. 2. Lets find an interesting module● Go to CPAN● Search for something funny in Text::● We found Text::UpsideDown● It turns text upside down!● OMGZ0x0ztrzzzz11!
  3. 3. Text::UpsideDown use Text::UpsideDown; my $text   = “Hello world!”; my $updown = upside_down($text);● Okay, thats pretty simple
  4. 4. Installing Dancer
  5. 5. Installing Dancer
  6. 6. Creating the skeleton● Dancer installs an app called “dancer”● Run it to create a directory structure● Pretty default design for free!
  7. 7. Adding code● Edit main path in lib/UpsideDown.pm # default path get / => sub {   # code to run when someone goes   # to the main page };
  8. 8. Adding code● Suppose we get user text with a parameter● Use Dancers “params” to reach it● If its called “text”, all we have to do is... my $text = params­>{text};● Then to turn it upside down... my $updown = upside_down($text);
  9. 9. What do we have so far?● Someone reaches main page● We get text and turn it upside down use Text::UpsideDown; get / => sub {     my $text   = params­>{text};     my $updown = upside_down($text);     ... };
  10. 10. Rendering it● Render template “view/index.tt”● Send it the original text and the upside down template index => {     text       => $text,     upsidedown => $updown, };
  11. 11. Putting it all togetheruse Text::UpsideDown;get / => sub {  my $text = params­>{text};  my $updown = upside_down($text);  template index => {    text       => $text,    upsidedown => $updown,  };};
  12. 12. Now the template● Edit index.tt file● Add a form to send text● Add a text input to write the text● Display the upside down text● Provide a button to submit more text● …● Profit!
  13. 13. Creating a form<form method=”post”> <!-- stuff goes here --></form>
  14. 14. Adding a text input box<form method=”post”><input type=”text” name=”text” value=”<% text | html %>” /></form>
  15. 15. Adding upside down text<form method=”post”><input type=”text” name=”text” value=”<% text | html %>” /><code><% upsidedown | html %></code></form>
  16. 16. Add button to submit form<form method=”post”><input type=”text” name=”text” value=”<% text | html %>” /><code><% upsidedown | html %></code><input type=”submit” value=”Upside Down!” /></form>
  17. 17. Hit it!
  18. 18. upsidedown.casa.darkpan.com
  19. 19. Dancer available @ http://perldancer.org Credit: Marco Fontani (http://darkpan.com)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×