June 15, 2008

A Simple Home Page on Google App Engine

I wanted to get a simple home page on Google App Engine - I may someday migrate a version of www.dr-chuck.com to Google App Engine because I am a firm believer in things that are free :)

So my new really light home page is http://dr-chuck.appspot.com/. For now it is just some static HTML with some links.

But I wanted to make it an expandable application so I made it do a simple template and use the pattern where the program becomes an application server. So here is the code:

cat app.yaml 

application: dr-chuck
version: 1
runtime: python
api_version: 1

handlers:
- url: .*
  script: index.py

cat index.py
#!/usr/bin/env python

import os
import wsgiref.handlers
from google.appengine.ext.webapp import template
from google.appengine.ext import webapp

class MainHandler(webapp.RequestHandler):

  def get(self):
    path = os.path.join(os.path.dirname(__file__), 'index.html')
    self.response.out.write(template.render(path, { }))

def main():
  application = webapp.WSGIApplication([
     ('/', MainHandler)],
                                       debug=True)
  wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__':
  main()


cat index.html 
<h2>Welcome to Dr. Chuck's Page</h2>
<p>You probably are looking for
<a href=http://www.dr-chuck.com/>www.dr-chuck.com</a> - 
that is where I keep my resume, photos, etc. </p>

.....
Posted by csev at June 15, 2008 11:36 AM