Hosting A Static Website In Google App Engine - Eclipse, Java

A few months ago, I played around with Google app engine. Somebody asked to set up a personal website which is nothing but a collection of static pages, images and JS widget to do a carousel/gallery. I tried my hand at Google app engine. In another instance, I hosted Google Course Builder on app engine. In both instance, my experience is smooth. Used Google app engine launcher.  Configured .yaml file (Replace application name with the unique application name you set up on google.)What if you want to setup your site using Java on AppEngine. Generally, java developers start with Eclipse. Generally, we follow the tutorial by Google. 
https://cloud.google.com/appengine/docs/java/gettingstarted/introduction

The question is how to put our static files on AppEngine and point index.html as the startup page. Answer - include static file location to app-webengine.xml. 
In this case I created "static" folder under war folder. Also, set the expiration date. Using this setting, server will ask the browser to invalidate the cache for every 30 days and 5 hours. 

<static-files>
        <include path="/static/**" expiration="30d 5h" />
 </static-files>

Next step is to set this folder as the public root. index.html which is configured in web.xml, will be picked up from this folder. 

<public-root>/static</public-root>

Gist: https://gist.github.com/pradeepkumargali/991f02d07c8177028203

The final output can be found at http://sree-kumar.appspot.com. 

References:
http://www.hongkiat.com/blog/host-website-google-server/
http://www.fizerkhan.com/blog/posts/Free-Static-Page-Hosting-on-Google-App-Engine-in-a-5-minutes.html

Comments

Popular posts from this blog

Updating SourceData/ Data Source of the Pivot Table

Salesforce.com migration tool - Deploying Weblink and migrating files with special characters

Information Architecture - Setup your term store to scale