forked from PerlDancer/perldancer-website
/
quickstart.tt
58 lines (44 loc) · 1.1 KB
/
quickstart.tt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<h2>Installing Dancer</h2>
<p>
Install Dancer via CPAN:
</p>
<pre class="shell">
$ sudo cpan Dancer
</pre>
<h2>Creating an application</h2>
<p>Since version 0.9904, an helper is shipped with the distribution
and lets you create an application with a single command:
<pre class="shell">
$ dancer -a mywebapp
+ [D] mywebapp
+ [F] mywebapp/config.yml
+ [D] mywebapp/views
+ [D] mywebapp/views/layouts
+ [F] mywebapp/views/layouts/main.tt
+ [F] mywebapp/views/index.tt
+ [D] mywebapp/environments
+ [F] mywebapp/environments/production.yml
+ [F] mywebapp/environments/development.yml
+ [F] mywebapp/mywebapp.pm
+ [F] mywebapp/mywebapp.pl
+ [F] mywebapp/app.psgi
</pre>
<p>Everything is ready and works out of the box. It's already a working "Hello
World" application waiting for being hacked.</p>
<h2>Hacking into the routes</h2>
<pre class="prettyprint">
# myapp.pm
use Dancer;
get '/' => sub {
'Hello world!'
};
# add other routes here and there...
dance;
</pre>
<h2>Running the dance</h2>
<pre class="shell">
$ cd mywebapp
$ ./mywebapp.pl
>> Listening on 127.0.0.1:3000
== Entering the dance floor ...
</pre>