Alex Gomez
Alex Gomez

Reputation: 11

Starting web development with Perl Dancer2

I start with the typical 'Hello word': (i'm using Fedora 30 )

(file name Web.pl)

#!/usr/bin/env perl
use Dancer2;

get '/' => sub {
   "Hello World!"
};

dance; 

then I execute in the terminal:

$ perl Web.pl

it gives me this:

Dancer2 v0.300000 server 12191 listening on http://0.0.0.0:3000

then I try:

$ curl http://0.0.0.0:3000

and it gives me this answer:

curl: (7) Failed to connect to 0.0.0.0 port 3000: Connection refused

What am I doing wrong?

Upvotes: 1

Views: 212

Answers (1)

Miro J.
Miro J.

Reputation: 4954

As @simbabque suggested, you need to keep the app running in the original terminal and open another one to call the same end-point. The process, thus the server, stops when you try to use the same one.

Upvotes: 2

Related Questions