Getting Started with Google App Engine

March 26th, 2012 Leave a comment
Like the article?
Getting started with Google App Engine

When creating web applications it is easy to get distracted with concerns about hardware and load when all you want is to write your code. Google’s App Engine creates an easy way to get started with your web applications on the same systems that host Google applications. Using the App Engine is easy but it can seem daunting at first. I have written this step-by-step guide to help you get started.

Google App Engine is Google’s platform for developing and running web applications on their infrastructure. There are a lot of benefits to running your applications in the Google App Engine, such as: high scalability, reliability, speed and the peace of mind to only worry about your code and not infrastructure concerns.

Applications developed on the Google App Engine are written in either Python or Java. Currently Python version 2.5 is supported. The App Engine has a number of APIs for storing data, cron jobs, caching and other functionality that you can use to create your apps.

Step 1: Getting Registered.

Your first step is to get registered at:

If you already have a Google account, you just need to login and authorize the App Engine to access your account.

Step 2: Choose a language

Download and install Python 2.5:

so you are prepared to develop web applications in Python or get a Java IDE if you wish to write in Java.

Step 3: Download and install the App Engine SDK that is correct for your operating system and language

The SDK contains several tools such as the development environment similar to the App Engine and the App Launcher program that will allow you to publish your applications to the platforms.

Step 4: Become familiar with the App Launcher tool

The App Launcher will allow you to start and stop your applications as well as deploy them to the platform. You should create your web applications locally and then publish them with the App Launcher when you are ready. Some of the important features:

  • The Run button will start a web server instance which will allow you to test your applications and how they will run in the App Engine environment.
  • Browse will open the project in the default browser.
  • SDK Console will allow you to access the management of the integrated database, which your application can use to store data.
  • Deploy will upload the web application to the platform and set it up on an .appspot.com domain.

Step 5: Set up your project

Each App Engine application you create requires several different configuration files in the root folder. These files are generated and are: main.py, app.yaml, index.yaml and cron.yaml as well as the following folders:

  • Assets for images, stylesheets and js files
  • Config for a Python configuration file
  • Models, Views and Controllers for Python source files according to the MVC pattern

Main.py is the file that is accessed when a new request is made of your web application. It is the file that contains the instructions for making requests to different controllers.

The index.yaml file is automatically created by the Launcher when you create your application. This is the file where we can define the indexes that will be used by the Datastore. Indexes are important since they speed up the queries you will be making and some will be created automatically for simple queries.

Step 6: Set up the configuration files

The App Engine configuration files define the language that our application will be using as well as its unique identifier and version. Configuration files are written in the YAML format which is designed for easy data serialization. You will find that they are excellent for storing configuration data and can hold data types that you would normally find in a programming language such as arrays, strings and numbers.

The app.yaml is the main configuration file in the application. It is automatically created and populated by the App Engine launcher when you create a new application.

A quick tour of the file:

  • app.yaml contains the application identifier and version number. The identifier is assigned to your application and is generated by the Launcher. App Engine can manage different versions of your application, so the difference in version number is important.
  • The bulletins directive builtins:- datastore_admin: on is what will allow us to use the Datastore and the Datastore Administration screen in the control panel. Without this directive you would be unable to store data in the Datastore.
  • The handlers allow us to route URLs to the script that handle them, specified by a regular expression. You will need to specify you static files using either static_files or static_dir directives.

Step 7: Set-up the cron service

The crons.yaml file controls and configures the cron service. Basically, we tell the cron script to access the necessary URLs where our scripts reside on the schedule we set. The ease of use of the cron jobs in the App Engine is especially nice. We do not need to setup anything special to access and execute our scripts from the cron.

Step 8: Write your code

By far our longest step. Since we now have a configured App Engine application, we can begin writing the code necessary for our application. Many applications take advantage of the Google Webapp Framework to help build their application. The Webapp framework comes with the SDK so you don’t have to install anything else. The Webapp framework will allow you to organize our code in the Model-View-Controller pattern of MVC.

Step 9: Set up views

Views are basically HTML files that have a lot of template tags which can be used by a templating engine. The engine scans the file and inserts dynamic content according to a special syntax, such as: {{variable}}. These are replaced with the actual contents of the variables when the template is generated.

Step 10: Create a front end

Depending on your application, you may need different parts to the front end of your application. AJAX, JSON, CSS and jQuery techniques are commonly used in conjunction with the Datastore data to create rich, enhanced pages for your application.

Conclusion

There it is in 10 steps! Whether your application is large or small, there are the steps that you need to follow to create a web application in the Google App Engine. App Engine offers a fast development environment, simple administration and the dedicated up-time that Google can provide. Without the need for infrastructure concerns such as patching, hardware and backups, you are free to create applications and focus on the complex problems.

Relevant Links:

Help us spread the word!
  • Twitter
  • Facebook
  • LinkedIn
  • Pinterest
  • Delicious
  • DZone
  • Reddit
  • Sphinn
  • StumbleUpon
  • Google Plus
  • RSS
  • Email
  • Print
Don't miss another post! Receive updates via email!

Comment