Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- post '/new' => sub {
- my $title = request.params<title> // '';
- my $text = request.params<text> // '';
- my $id = 1;
- try {
- $id = get_id();
- }
- my $pubdate = now;
- my %a = 'id' => $id,
- 'title' => $title,
- 'pubdate' => $pubdate,
- 'text' = $text;
- my $json = to-json(%a);
- my $filename = 'data/' ~ $id ~ '.json';
- my $fh = open $filename, :w;
- $fh.say($json);
- $fh.close();
- say 'Article enregistré !';
- };
- $ perl6 app.p6
- Entering the development dance floor: http://0.0.0.0:3000
- [2016-02-16T14:51:35Z] Started HTTP server.
- [2016-02-16T14:51:42Z] GET /new HTTP/1.1
- [2016-02-16T14:52:18Z] POST /new HTTP/1.1
- Cannot modify an immutable Str
- in sub at app.p6 line 44
- in sub dispatch at /home/emeric/.rakudobrew/moar-2015.12/install/share/perl6/site/sources/5697700BC6E98F8C57CCB13BC967A5F8C7E84E9E line 137
- in sub dispatch-psgi at /home/emeric/.rakudobrew/moar-2015.12/install/share/perl6/site/sources/5697700BC6E98F8C57CCB13BC967A5F8C7E84E9E line 157
- in method handler at /home/emeric/.rakudobrew/moar-2015.12/install/share/perl6/site/sources/C31909E8F4ABB3D9DBB1235E43CF6EA2A59BE75A line 34
- in method run at /home/emeric/.rakudobrew/moar-2015.12/install/share/perl6/site/sources/7FC10A725DD1B287E23A8BF3056BA3C22A2F2BBD line 184
- in sub baile at /home/emeric/.rakudobrew/moar-2015.12/install/share/perl6/site/sources/5697700BC6E98F8C57CCB13BC967A5F8C7E84E9E line 165
- in block <unit> at app.p6 line 57
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement