Paco is really excited about what he's heard
about the benefits he'll receive
from making his application with Google App Engine.
Since he's not familiarized with the platform,
he decides to start from zero with the most basic application,
an application that shows the home page or landing page
to users upon accessing. This way he'll become familiar
with it and begin to develop it with a solid foundation.
THE GOOGLE APP ENGINE SDK
Before beginning to develop the first thing Paco needs to do
is download and install SDK on his computer:
Google App Engine "Software Development Kit."
It's a software package with different tools
that will allow him to interact with the platform
during the entire lifecycle of his application.
It's possible that Paco and his work team
use computers with different operative systems
during application development.
This is not a problem, since SDK
is adapted for the different operative systems,
Windows, Mac or Linux.
As for programming language or run time,
they are currently supported by Google App Engine,
Python 2.7, Java 7
and languages run by JVM,
Php 5.4 and Go.
Paco has always been a big fan of Python
and wants to use it for this project.
Not just because he's familiar with the language,
but because it offers coverage
for the majority of platform services.
The only prerequisite is having Python SDK installed.
Paco is ready to continue with the installation.
But what exactly does SDK include?
A local web server that allows us
to run the applications on our computers.
A tool that allows us to upload local code
to the production environment.
A process known as deploy.
Personal APIs and libraries that offer programming access
to Google App Engine services.
Third-party libraries,
included because they are dependents of Google App Engine
personal libraries or because they are usually used
for developing most applications.
Applications or additional tools
that help the development process.
Optional integration with Integrated Development
Environment (IDE), specifically for Java runtime
an official plug-in for Eclipse is included.
Keep in mind that even though SDK runs locally,
it's in charge of closely emulating
the Google App Engine production environment.
So you will notice that resources are restricted
to those that won't have access
or features that won't be available to the sandbox.
For example: access to the file system
or the system's low-level features.
SDK code is open.
And it is frequently updated with new characteristics
and improvements to existing features.
APPLICATION STRUCTURE AND BASIC COMPONENTS
With SDK installed,
Paco is ready to develop his application.
As with any web application, this implies
having a small part of the configuration
in a file called app.yaml,
plus a file with the content
that will initially be shown in the application,
a simple, landing page.
In the file app.yaml, Paco will define
the basic configuration of his application.
By using an application written in Python,
the yaml format will be used in the following fields:
Application: used to assign
a unique identifier to the application.
Version:
defines the name of a code version of the application.
Google App Engine allows there to be
various versions of the application at the same time.
Runtime: corresponds to the name
of the execution environment
used to run our application.
In Paco's case,
we will use the runtime python27.
Api_version: specifies the API version
that we will use for a determined runtime.
There currently exists a unique API for the Python runtime.
Threadsafe: configures our application
so that every instance
is able to execute concurrent processes,
we normally use the "true" value
in Python applications.
Handlers: define expressions
that allow URLs to be assigned to the scripts
that will attend to the http applications.
We can also define routes
that will deliver static HTML files,
CSS style pages,
Java scripts or images, among others.
For any App Engine application,
the mentioned fields will be obligatory.
For the application with the census landing pace,
Paco will define two handlers.
The route /index.html
will directly serve the index.html file
with the landing page content.
All the content whose route begins with /assets
will be served as static files
from the static file of the application.
Paco copies an image file with the census logo,
called logo.png, in the static file,
which has an HTML reference.
THE DEVELOPMENT SERVER
After finishing with the files,
Paco feels very anxious and wants to see
that everything really works as hoped.
To do this, he uses a very important component
that is included with the SDK, the development web server.
This will allow him to execute his application locally,
before unfolding it.
In other words,
the development server is ideal for testing
and validating the application's general behavior.
To start the local development server
Paco has three alternatives:
use Google App Engine Launcher
a GUI available for Linux, Mac and Windows,
the dev_appserver.py command
through the command line,
or an IDE.
Eclipse and Pycharm offer plug-ins
to directly complete this action.
LET'S GET TO WORK!
Launching the local server using the launcher
is very simple.
Paco adds the file that contains his application
and then just clicks on the "Run" button.
The local server will start serving his application
in port 8080.
Alternatively
the personal terminal to his operative system opens
and is located in the application root directory,
where the app.yaml file is also located.
Paco writes the following command.
Upon starting, the local server sees messages in the terminal
that indicate the port where his application launched.
To see his landing page in the development web server,
Paco enters the URL address localhost:8080,
from any navigator.
Upon entering, a GET application is created
to the root route, slash,
and it is answered
with the content index.html file
described in the prior section.
This way Paco validates
that the content shown on the navigator
corresponds to the landing page,
including the logo image in /assets.
Paco could launch the application
and did tests on his local machine.
Now it's your turn to experiment with the repository
and launch the landing page.
In the following lessons, we will review the steps
necessary to publish on Google App Engine.
Keep programming.