Charles Engelke's Blog

July 30, 2008

Google AppEngine for web hosting

Filed under: How To — Charles Engelke @ 10:45 pm
Tags: ,

Shortly after I first got my own domain I decided to run all the services myself.  It was a good experience but eventually got old, so I’ve been migrating everything to hosted services.  Free hosted services if possible.

DNS went first.  When I first registered my domain the registrar would only register my nameservers, which I then had to manage.  But now they (and apparently all registrars) will manage my nameservers for me through a simple web dashboard.  Step one was done and it was free as part of my domain registration.

Next came e-mail.  Before I ran my own mail servers I had a mail hosting provider, which cost $25 per month back then.  But now I can get mail hosting for free from Google Apps.  It’s easy to use and works great.  If you don’t have your own domain name, you can also register one through them for just $10 per year.

I’d been running my own Movable Type installation for my blog.  I considered moving to hosted TypePad, but I’d heard good things about WordPressWordPress.com now hosts my blog, also for free, but I decided to pay $10 per year to have it at my own domain name.  I love their service.

And now I’d migrated everything but my core web site, which is very minimal.  All I’ve got is a home page and a small number of other pages, because I’d already migrated my photos to Picasa web albums and my presentation files to Google Docs (which is also available as part of Google Apps), all for free.  There is one hitch, though: when I moved to a hosted blog all my old URLs changed, so my main web site has to redirect requests for the old URLs to the correct new ones.  But still, I didn’t want to pay for full web hosting for what is essentially just a starting point.

Google AppEngine to the rescue.  It’s a neat platform for a fancy web application, but it can also be a minimal web server.  It’s hosting my site now, and here’s what’s involved in doing it.

First, register an application name for AppEngine.  You’ll need a regular Google Mail account for this, but that’s easy to get.  It doesn’t matter what you call it; mine was engelkeweb.

Next, create a local folder on your machine to hold your application.  Put a folder inside that containing all your web pages.  It can be called anything, but the AppEngine examples always call it static, so that’s what I’ll do.  If your application folder is at C:\MyAppEngine then this folder will be C:\MyAppEngine\static, and the main home page would probably be C:\MyAppEngine\static\index.html.

Now create a text file called app.yaml in the main folder (in this example, at C:\MyAppEngine\app.yaml) with the following contents (change the engelkeweb entry to the name you registered):

application: engelkeweb
version: 1
runtime: python
api_version: 1

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

- url: /
  static_dir: static

Now upload your application (actually, just the static pages and the app.yaml file) using the command:

appcfg.py update C:\MyAppEngine

Voila!  You’ve got a simple static web site.  The second handler specification (for url: /, handled by static_dir: static) means that AppEngine will serve the page static\folder\xyz.ext whenever a user requests http://engelkeweb.appspot.com/folder/xyz.ext.  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://engelkeweb.appspot.com/folder/ would return the file static\folder\index.html.

Note that the order of the handler specifications matter, since the first one matched is what is returned.

You can use your Google Apps settings page to make this site available at your domain’s normal address, too (so in my case, that same page is returned for http://www.engelke.com/folder/xyz.ext and http://engelke.com/folder/xyz.ext).  You have to set up some DNS entries for that, but the Google Apps pages give clear explanations of what to do.

That’s how I’m now serving up engelke.com.  But what about the redirection for my blog pages?  Every URL of the form http://engelke.com/blog/something should now be redirected to https://blog.engelke.com/something.  Doing that requires actually writing a very simple Python handler for the site, just 20 lines long, and adding another handler specification in the app.yaml file.  I’ll cover that in my next post.

Advertisements

12 Comments

  1. […] Filed under: How To — Charles Engelke @ 8:43 pm Tags: appengine, google Yesterday I showed how to get a basic static web site hosted on Google AppEngine.  But I need a little bit […]

    Pingback by AppEngine “Rewrite Rules” « Charles Engelke’s Blog — July 31, 2008 @ 8:44 pm

  2. your blog is getting better )

    Comment by funnygirl — August 7, 2008 @ 9:25 am

  3. Awesome, thanks

    Comment by bert — August 10, 2008 @ 3:14 am

  4. Appreciate the post. Still trying to get my hands around App Engine and just wanted to post some simple statics to get started. Your directions were simple and straight forward. Also, have a transition plan as Google moves everything from pages to sites… Big thanks for that.

    Comment by matt — February 18, 2009 @ 9:28 am

  5. […] Next, download the development environment. Now you are ready to create an app. You can go for something really simple, or leverage Python and Django to build something more robust. If you just want a simple static home page, head on over to Charles Engelke’s blog to see how to set it up. […]

    Pingback by Terminally Incoherent » Blog Archive » Your Homepage on Google AppEngine — February 23, 2009 @ 1:31 pm

  6. “You can use your Google Apps settings page to make this site available at your domain’s normal address, too (so in my case, that same page is returned for http://www.engelke.com/folder/xyz.ext and http://engelke.com/folder/xyz.ext). You have to set up some DNS entries for that, but the Google Apps pages give clear explanations of what to do.”

    Could you please help me how to achieve this? I have spent so many hours but it redirects http://nakeddomain.com/what/ever to http://www.nakeddomain.com/.. Please help me..

    Comment by Peter G — March 4, 2009 @ 3:09 am

  7. […] appengine, google I’ve been getting some comments recently on last summer’s post on Google AppEngine for web hosting.  I guess I’m not the only one who wants to add some simple static web pages to my Google […]

    Pingback by Update: Web Hosting with Google AppEngine « Charles Engelke’s Blog — March 4, 2009 @ 9:56 pm

  8. I’ve posted an update to this entry talking about the naked domain problem. Google Apps apparently no longer supports this directly, but you can use a service from your domain registrar to get the job done.

    Comment by Charles Engelke — March 4, 2009 @ 9:57 pm

  9. EXACTLY what I have been looking for!

    Thanks for the post and info.

    Comment by Dan — May 5, 2009 @ 10:21 am

  10. […] to plunk down my static we pages I found a blog post by Charles Engelke that describes how to use Google AppEngine for web hosting of static web pages–exactly what I’m looking for… […]

    Pingback by SQL Server Central — February 5, 2010 @ 8:44 am

  11. […] to plunk down my static we pages I found a blog post by Charles Engelke that describes how to use Google AppEngine for web hosting of static web pages–exactly what I’m looking […]

    Pingback by Providing Online Help for Powershell Modules | Sev17 — March 21, 2010 @ 11:15 am

  12. I really appreciate this. I’ve been looking all over the web for this exact information.

    I don’t know why Google can’t make it more clear. They act like yu have to write a whole Java or Python application and – as you make clear and my tests now show – YOU DON’T!!!

    Thanks again. Now I can get to work transferring my sites over without having to learn Python until I am ready.

    Comment by Bob James — August 12, 2010 @ 1:29 am


RSS feed for comments on this post.

Create a free website or blog at WordPress.com.

%d bloggers like this: