Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Web service without a server

by thomas895 (Deacon)
on Mar 17, 2014 at 04:18 UTC ( [id://1078568]=note: print w/replies, xml ) Need Help??


in reply to Web service without a server

I think you need to step back and get the fundamentals down before attempting to make a web service right away. Moreover, your question is contradictory, without having a web server installed or available, it follows that it is illogical to attempt to do anything for or with it.

A web server is not a "file"(as you are likely imagining it) that can be saved like a text document or image. Surely you must have learned the fundamentals of the web server within the introductory part of whichever course you follow or book you are reading. If not, you may want to reconsider your investment.

The most I can recommend is to follow the tutorials presented for popular solutions such as Dancer or Catalyst.
Also, see How do I post a question effectively?.

~Thomas~ 
"Excuse me for butting in, but I'm interrupt-driven..."

Replies are listed 'Best First'.
Re^2: Web service without a server
by marto (Cardinal) on Mar 17, 2014 at 08:56 UTC

    I think this is a typo:

    "web service without need of a web service"

    And what they mean is that they have to make a script send a response to a browser, without having a traditional webserver (apache and so on) installed.

      thank you for correcting the typo, yes I'm looking for some answers related to 'Web Service' without a need of installing ' a Traditional Web Server'
Re^2: Web service without a server
by rudrakiran (Initiate) on Mar 18, 2014 at 03:01 UTC
    Thomas, appreciate your time ! but you should know how to respond, mistakes do happen !

      I just wish I did! Now that you've updated your question to be more specific, I can once again recommend Dancer, Catalyst, Mojolicious(::Lite), or even HTTP::Server::Simple.

      Here is an example of your desire(borrowed code from the latter):

      #!/usr/bin/perl { package MyWebServer; use HTTP::Server::Simple::CGI; use base qw(HTTP::Server::Simple::CGI); my %dispatch = ( '/bla' => \&resp_bla, ); sub handle_request { my $self = shift; my $cgi = shift; my $path = $cgi->path_info(); my $handler = $dispatch{$path}; if (ref($handler) eq "CODE") { print "HTTP/1.0 200 OK\r\n"; $handler->($cgi); } else { print "HTTP/1.0 404 Not found\r\n"; print $cgi->header, $cgi->start_html('Not found'), $cgi->h1('Not found'), $cgi->end_html; } } sub resp_bla { my $cgi = shift; # CGI.pm object return if !ref $cgi; print $cgi->header("text/plain"), (rand(10) < 5) # pick a random number and see if it is less + than 5... ? 1 : 0; #...and print 1 if it is, or 0 if it isn't. } } # start the server on port 8080 # access me at http://localhost:8080/bla my $pid = MyWebServer->new(8080)->background(); print "Use 'kill $pid' to stop server.\n";

      Of course, you will want to do a more interesting check than a random number -- say, whether a file exists, a row is present in a table, or if it is a certain time of day.

      ~Thomas~ 
      "Excuse me for butting in, but I'm interrupt-driven..."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1078568]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found