#!/usr/bin/perl
use warnings;
use strict;
use CGI::Carp qw(fatalsToBrowser);
use Mojolicious::Lite;
my $app = app;
my $version = Mojolicious->VERSION;
get '/' => sub {
$self->render( inline => <<HTML );
<!DOCTYPE html>
<html><head>
<title>Mojolicious Title App</title>
</head>
<body>
Mojolicious: $version <br />
</body></html>
HTML
};
$app->secret('p@$$w0rd');
$app->start('cgi');
Content-Type: text/html;charset=UTF-8 X-Powered-By: Mojolicious (Perl) Status: 200 OK Date: Sun, 21 Apr 2013 20:50:41 GMT Content-Length: 137 <!DOCTYPE html> <html><head> <title>Mojolicious Title App</title> </head> <body> Mojolicious: 2.23 <br /> Reading: </body></html>
get '/' => sub {
my $self = shift;
#1) How to get info about the host environment(something like CGI's @ENV)
# Some host environment info is modeled by Mojo::Message::Request
# which I guess is intended to emulate the HTTP request process
my $req = $self->req;
# $req can now be used to access other objects like header, url,
# and env, this last being a hash which is equivalent to @ENV if
# running Mojolicious within a CGI environment [ with app->start('cgi') ]
my $URL = $req->url; # now we should be able to display parts of the URL...
#say $URL;
#say $URL->host;
my $base_url = $URL->base;
my $mojoENV = ( join "\n<br />", sort keys %{$req->env} );
#2) How to use inline text to "render" HTML
$self->render( inline => <<HTML );
<!DOCTYPE html>
<html><head>
<title>Mojolicious Title App</title>
</head>
<body>
Mojolicious: $version <br />
Reading: $base_url <br />
ENV Vars: $mojoENV
</body></html>
HTML
};
I also had a 'say' statement in there ...
--
You received this message because you are subscribed to a topic in the Google Groups "Mojolicious" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mojolicious/grivePrVtMg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "Mojolicious" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mojolicious/grivePrVtMg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.