The smallest app ever
The following app.yaml is a complete App Engine application. Just drop your entire webpage into a subfolder called "static", and it will be served:application: mysite
version: 1
runtime: python
api_version: 1
handlers:
- url: /(.*)
static_files: static/\1
upload: static/(.*)
What does it do? Well, the regular expression "/(.*)" stands for "every request coming in." The following line instructs the application to look for a static file with the same name in the "static" subfolder. Last but not least, we also tell the application to upload that entire folder as static content into the application.
In other words, for the simplest of all cases, we can turn our webpage into an App Engine application with just a little bit of configuration magic. But wait, there is more:
Leveraging Templates
A lot of App Engine users these days seem to be requesting PHP. There certainly are many good reasons for that, but I kindof wonder if some purposes PHP is used for cannot be easily handled with Django templates. If, for instance, you happen to use PHP simply as a way to not having to copy and paste the same header and footer each and every time, App Engine is the right tool for you.Take a look at Training Wheels. This site is a simple extension of the
app.yaml shown above that serves pages in a slightly more sophisticated manner:- requests that do not end with "django" or "djhtml" are served as static content
- "django/djhtml"-requests are considered Django templates that should be executed
4 comments:
Thanks for sharing technical tricks on GAE.
I referenced this post in mine describing GAE service: Google App Engine: Free Hosting and Powerful SDK.
Note also your post The darker side of multiplexing, or how to prevent site hijacking is mentioned in my same post;)
Your two articles shows how simple it is to put static webpages on GAE and to prevent that anyone reuse them abusively.
A+, Dom
A note for those trying to copy-paste this code(for example myself), additional spaces are required for the lines after "- url: /(.*)", they must have been nuked by the blog engine.
GAE has a limitation of allowing applications to store not more than 10MB of a single large file on it’s server. This may not be a problem for some of the web applications. This is a serious issue for many web applications which assume sufficiently large underlying storage,
Many like me have tried and realized the same as in this blog
http://bygsoft.wordpress.com/2010/01/09/cloudy-combo-google-app-engine-and-amazon-s3-combo-pack/
> GAE has a limitation of allowing applications to store not more than 10MB of a single large file on it’s server.
Correct, thanks for pointing that out. In the article, I am mentioning file size limitations and recommend an alternate location for those files (in the example, I am using sites, but it could basically be anything)
Post a Comment