Portable Google App Engine For Windows


Update: An enhanced version of this tutorial has been published that is a lot more efficient and more powerful.

Recently, I’ve been playing with Google App Engine.   It is a neat platform and I wanted to take it around with me so I could develop anywhere. To get a portable version of Google App Engine for Windows you need to download the following:


Installation

Grab a USB thumb drive and install Portable Python to it.

Extract the “google_appengine” folder from the Google App Engine SDK zip file into the PortablePython folder on your thumb drive.

Create a new folder in your PortablePython directory called “google_appengine_datastores”.


Creating your Application

All your application folders will go in the PortablePython folder along side the google_appengine folder.   For this example, I’ll walk you through creating the first step of the HelloWorld Tutorial on the main Google App Engine site.

Create a new folder in your PortablePython directory called “HelloWorld”.

Create a new file called “helloworld.py” in this folder with the following contents:

print 'Content-Type: text/plain'
print ''
print 'Hello, world!'

Create a new file called “app.yaml” in the same folder with the following contents:

application: helloworld
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: helloworld.py


Running your Application

Alright, now that we have the physical files for our first Application.  Lets see how it looks.  Double click on “IPythonShell-Portable.exe” in your PortablePython directory.  It might take a minute if this is your first time running this program.

Once you get to the IPython shell, type the following command:

%run google_appengine/dev_appserver.py --datastore_path=google_appengine_datastores/helloworld_datastore --history_path=google_appengine_datastores/helloworld_history helloworld/

Hit the enter button and it should being running.  This starts the development webserver and loads our HelloWorld application.  Open your browser and go to http://localhost:8080 to execute the Application.  You should see “Hello, World!” in your browser.  The datastore_path and history_path command line parameters from above will store the datastore and query history information into the “google_appengine_datastores” directory that we created earlier.   If you don’t include these, the datastore will not be portable as it will save to your local system hard drive.   I like to add the project name into the datastore and history path so that I could clear only the datastore for a specific project that I’m working on.

If you want to create a batch file that runs your application you can use the following command line in the batch file (You should create it in the root of your PortablePython directory):

apppython.exe google_appengine/dev_appserver.py --datastore_path=google_appengine_datastores/helloworld_datastore --history_path=google_appengine_datastores/helloworld_history helloworld/


Continued Development

Your application is now running!  You can leave the IPython shell running in the background while you develop in an IDE like SPE or PyScripter.  As you modify your source, the development web server will reload your modified code so you don’t have to restart it all the time.

You now have a fully functioning Portable Google App Engine development environment!  If you ever need to update the Google App Engine SDK, just delete the google_appengine folder from your PortablePython directory and extract the new one from the main download site.

Warning:  One slight oddity that appears, is if you try to close the IPython window by hitting “Ctrl + C” you have to refresh the website before IPython will acknowledge and stop the server.

Advertisements

6 thoughts on “Portable Google App Engine For Windows”

  1. Hi good article!

    I’ve tried to follow it but when I was trying to run the hello world app I’ve received the following message in the IPython Shell:

    WARNING 2010-12-09 15:13:02,155 datastore_file_stub.py:573] Could not read datastore data from D:xampppython2PortablePython_1.1_py2.5.4google_appengine_datastoreshelloworld_datastore

    I’ve tried to manually created the ‘D:xampppython2PortablePython_1.1_py2.5.4google_appengine_datastoreshelloworld_datastore’ folder but I’m still receiving the warning.
    No new folders nor files were created under ‘D:xampppython2PortablePython_1.1_py2.5.4google_appengine_datastores’

    How can I solve this?

    BTW,
    there is no normal way to stop the application? just ctrl+c and refreshing?

    1. The warning message will always happen the first time you run your application without having anything in the datastore. The “google_appengine_datastoreshelloworld_datastore” will actually end up being a file called “helloworld_datastore” instead of a directory. At the moment, the only way I’ve found to close it is the Ctrl+C way. I may look into alternatives soon.

      I’m currently working on a article that updates my Portable Google App Engine for the latest SDK and using a few of the newer features. That’ll be coming within the next week.

      1. Really thanks for your fast reply!

        Yes you right, I’ve just tried the datastore example from http://code.google.com/intl/iw-IL/appengine/docs/python/gettingstarted/usingdatastore.html and it’s working perfectly.

        I’m waiting for your next article…

        If you could add a plugin to subscribe for new articles / comments it would be great!
        Something like:
        http://wordpress.org/extend/plugins/subscribe2/ or
        http://wordpress.org/extend/plugins/subscribe-to-double-opt-in-comments/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s