forked from PerlDancer/Dancer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
135 lines (81 loc) · 3.19 KB
/
README
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
Dancer
The easiest way to write a webapp with Perl
=== ABOUT ===
This project is inspired by Ruby's Sinatra framework: a framework for building
web applications with minimal-effort, allowing a simple webapp to be created with
very few lines of code, but allowing the flexibility to scale to much more
complex applications.
=== NEWS ===
Dancer's development moves very fast, to stay tuned follow
sukria on Twitter: http://twitter.com/sukria or his blog
http://sukria.net/fr/tag/Dancer
See also the project on Github for the latest changes:
http://github.com/sukria/Dancer
=== EXAMPLE ===
To create a new Dancer application, use the helper script "dancer" provided
with this distribution:
$ dancer -a mywebapp
+ mywebapp
+ mywebapp/config.yml
+ mywebapp/views
+ mywebapp/views/layouts
[..]
You then have a new Dancer application in 'mywebapp', which is already a
functioning "Hello World" application, ready for you to work upon.
Here is an example of a webapp built with Dancer:
# webapp.pl
#!/usr/bin/perl
use Dancer;
get '/' => sub {
"Hello There!"
};
get '/hello/:name' => sub {
"Hey ".params->{name}.", how are you?";
};
post '/new' => sub {
"creating new entry: ".params->{name};
};
Dancer->dance;
When running this script, a webserver is running and ready to serve:
$ perl ./webapp.pl
>> Listening on 0.0.0.0:3000
== Entering the development dance floor ...
Then it's possible to access any route defined in the script:
$ curl http://localhost:3000/
Hello There!
=== DEPENDENCIES ===
Dancer depends on the following modules
- HTTP::Server::Simple::PSGI
- HTTP::Body
- Exception::Class
- MIME::Types
- URI
Optional modules may be needed if you want to use some features (but are not
required for a basic usage).
Dependency-checks for additional features are performed at runtime.
Most common modules you may want are:
- Template (for Template::Toolkit support)
- YAML (for configuration files)
- Plack (if you want to deploy your application with PSGI)
=== PRODUCTION MATTERS ===
This is a work in progress.
Dancer supports PSGI/Plack, to run a Dancer app with PSGI/Plack just bootstrap
your application with the helper script `dancer' like the following:
$ dancer -a MyWebApp
You'll find a file in there called `app.psgi', use this file to configure your
PSGI environment, as explained in the revelant documentation of your PSGI
server.
For instance, with plackup, just do the following:
$ plackup -a app.psgi
=== WEBSITE ===
For more details about the project, checkout the official website:
http://dancer.sukria.net/ or checkout the documentation at
http://search.cpan.org/dist/Dancer/
See also the Github project page: http://github.com/sukria/Dancer for the latest
changes.
=== REPORTING BUGS ===
Bug reports are appreciated and will receive prompt attention - the preferred
method is to raise them using Github's basic issue tracking system:
http://github.com/sukria/Dancer/issues
=== CONTACT ===
You can reach the development team on IRC: irc://irc.perl.org/#dancer