This application is a starting point for developers who want to build applications using the Hunch API. The application is built to run either as a standalone Django application or using Google App Engine.
This sample application will display recommendations for a single Hunch user by placing that user's AUTH_TOKEN in app/config.py. If you would like to generate recommendations for arbitrary Hunch users, obtain an APP_ID and APP_SECRET by e-mailing [email protected]. You will them be able to Hunch Connect (OAuth) users into your application and store their auth_tokens.
Other libraries used include:
- jQuery JavaScript Framework
- Mustache JavaScript templating library
- Hunch JavaScript SDK
- djangoappengine
-
Download the Google App Engine Python SDK
-
Configure initial settings
- in app/config.py, edit AUTH_TOKEN. Your AUTH_TOKEN can be found at the bottom of the Hunch developer docs (login and select "show my auth_token")
-
Test your app loads the test page
- run
python dev_server.sh
(this defaults to running on port 80 which may require root permissions) - open a web browser and navigate to http://localhost
- ensure that you see the success page
- now navigate to http://localhost/app/
- ensure that you see the recommendations being populated correctly
- run
-
If you want to Hunch Connect users into your application
- E-mail [email protected] to request an APP_ID and APP_SECRET
- in app/config.py, edit APP_ID and APP_SECRET you will receive for your Hunch application
-
When ready, deploy the app to GAE
- in settings.py, create a SECRET_KEY
- in app.yaml, edit app-name; in app/config.py, edit APP_HOSTNAME
python manage.py deploy
Start the development server
sh dev_server.sh
Publish your app to GAE
python2.5 manage.py deploy
Launch a local Python console for interecting with the app and datastore
python2.5 manage.py shell
Launch a remote Python console for interacting with the app and datastore
python2.5 manage.py remote shell
-
GAE will penalize your app if requests take over 1000 ms to complete, so push as many calls to the frontend as possible by using the Hunch Javascript SDK
-
This application is packaged with djangoappengine for creating Django projects that run on GAE. It is worthwhile to read the overview of using the helper.
-
GAE uses Python 2.5, so running scripts like
manage.py
with python2.5 is recommended. The scriptsdev_server.sh
andfresh_dev_server.sh
use python2.5 -
You can access the GAE admin console at http://localhost/_ah/admin/
-
For testing, it is useful to redirect your-app-name.appspot.com to your local machine. To accomplish this, edit your /etc/hosts file and point that address to your IP (or localhost)