Saturday, August 09, 2008

Here's a quick HOWTO on setting up your static website on Google AppEngine.
I promise to keep it very simple and easy to understand for my non-geeky friends

Registering an application:
Firstly register an application on Google AppEngine. It doesn’t matter what you call it, for this HOWTO lets name it mysamplesite.
You’ll need a regular gmail account to do this, hope you already have that (if not shame on you ;)).

Creating a local site and configuration file:
Create a local folder on your machine to for this project. Put a folder inside that containing all your web pages. It can be called anything, but the AppEngine examples always call it static. For our HOWTO lets call it home

Say if your project folder is at C:\MyWeb then this folder will be C:\MyWeb\home, and the main home page would probably be C:\MyWeb\home\index.html.
So now you have a local folder on your machine @ C:\MyWeb\home which holds your website.

Now create a text file called app.yaml in the project folder (C:\MyWeb\app.yaml) with the following contents (I hope you know that you have to change the mysamplesite entry to the name you registered):

application: mysamplesite
version: 1
runtime: python
api_version: 1
handlers:

- url: (.*)/
static_files: home\1/index.html
upload:
home/index.html

- url: /
static_dir: home

Creating the environment for upload:
The website and all related configuration is now ready for upload. Now you need to set up the enviroment for it. Don't worry I'll not ask you to do any coding, its simple "next-> next" kind of installation

# Download and install python from http://www.python.org/download/ and install it. (Simple "next->next" installation)
# Download and install Google AppEngine SDK from http://code.google.com/appengine/downloads.html (Nothing
to worry I promise)


Uploading the website:
Now its the time to upload your static website. All you have to do is run the following command from command prompt.
appcfg.py update C:\MyWeb

This will ask you for your email address. Enter the one you used for creation of application. Next it will ask for your gmail password, don't worry & type it too.
It will show some text and screen & BANG! your static website is up and running on Google AppEngine.

Now you can access your website by the url http://mysamplesite.appspot.com/ (change mysamplesite to your project name).

Explanation of app.yaml file:
The second handler specification (for url: /, handled by static_dir: home) means that AppEngine will serve the page home\folder\abc.xyz whenever a user requests http://mysamplesite.appspot.com/folder/abc.xyz. That’s 95% of a static web site. And the first handler specification (for url: (.*)/) says that any request to a URL ending with a slash should return the index.html page in that folder. So a request to http://mysamplesite.appspot.com/folder/ would return the file home\folder\index.html.

Changing the site name to your website name:
Obviously you don't want to show the world your website as mysamplesite.appspot.com. So now lets change the URL to your website name.
For this you need to have a Google Apps hosted domain. If you already haven't done that, go for it cause it will give you the following for free
a) email server: multiple email address with @yourdomain.com
b) Google docs
c) Calendar
d) Google talk
and much more... and all by your domain name.

Once you have the Google Apps account, go to https://www.google.com/a/cpanel/YOURDOMAIN.COM/SelectServices and enter your AppID (mysamplesite in our example)
Accept the terms and condition and create a name for your project.
Next you'll be asked to create a CNAME entry in your DNS. If you are new to this, read the documentation on the page and you'll be able to do it. Its not a rocket science anyway.
Once done you can access your new static website hosted on Google AppEngine by your own domain name.

That's easy, isn't it.

Benefits of site on Google AppEngine:
a) High end google servers
b) No worries of downtime
c) High availablity
d) No pain of maintaining the server settings if you have only static website
e) FREE !!! This can make your complete web presence for free. Blog @ Blogspot, Album @ Picasa, Website @ AppEngine, mail @ gmail ( or hosted google mail), presentations and files @ Docs. All you need to pay is cost of domain name(~$10).

4 comments:

Sushant said...

Hi Rohit
Thanks for your post.
It was really helpful, am bookmarking this as I am planning to deploy an app of mine on GAE (someday :P)
Thanks
Sushant Srivastava

kritz said...

Very informative.. Would surely like to try it..

Sorabh said...

Great Info...Very useful. Thanks

Aung Ko Myat said...

Thanks indeed for yr great post.
But can I use the domain that I bought with Godaddy other than Google Apps ?

Post a Comment