Jun 5, 2012

Getting starting with Google App Engine: Python

I have heard of the Google App Engine (a 'cloud' computing service) for a while now but never really had the opportunity to really use it. Luckily, I have a job on the horizon that seems like a perfect fit; a 'glue' app that connects two separate web apps together. I can simply host all the code onto Google's cloud, run a few CRON scripts to grab the data from one app and upload it to another.

But first, I need to learn how to tame this beast and get it to do my bidding....

What you need

First off, I am going to assume you have created a Google account and registered to use App Engine (you should be able to access the dashboard). You should also have Eclipse installed with the Google Plugin. I won't get into the details here since the reference links should provide you with adequate tutorials on how to set up each of the components.

Next, you should realize that this guide will only deals with Python for the App Engine environment. You can use Java and GO, but that is outside the scope of this guide. So if you don't know it yet, go ahead and brush up on some of your Python skills (and make sure it is installed on your machine AND Eclipse!).

Finally, go ahead and download the Google App Engine SDK for Python. Without this SDK you WILL NOT be able to create any projects!

OK, I'm ready. What's next?

  1. Fire up Eclipse and from the menu select 'File -> New-> Project'
  2. Expand the PyDev tree and select PyDev Google App Engine Project
  3. Give your project a name and check to make sure your settings are correct (for instance, are you using Python 2.5 or 2.7?)
  4. Did I mention that you need to download the Google App Engine SDK for Python? Download it, extract it, and locate the directory so that Eclipse can use it.
  5. Select the Python libraries you want to use (Defaults are good for our purposes)
  6. Now we need our details from Google such as our appid. Log onto the App Engine Dashboard, create an app and enter the appid into Eclipse. Note that for the rest of this tutorial I am going to assume you are using the Hello World template.
  7.  Right click on the project, select 'Run As' and choose the 'PyDev: Google App Run' option
  8. Depending on how you configured your Google SDK, it will start up a server on your machine on port 8080. Open up a new tab and navigate to http://localhost:8080/
  9. We should now see 'Hello, World!' on our screen. To upload the app to Google just right click the project and select the 'PyDev: Google App Engine' -> 'Upload' option
  10. A dialogue will open up and you may have to enter in some parameters such as you email address and password (note: for people who use 2-step verification, you WILL need to create an application specific password). 
  11. Wait until the dialogue displays FINISHED. Once it pops up you can now go to the URL displayed on the Google Apps Dashboard and see your app in action!

References

No comments:

Post a Comment

Thanks for contributing!! Try to keep on topic and please avoid flame wars!!