Example #1
0
from storehouse import StorageConfig, StorageBackend
import traceback
from pprint import pprint
from esper.stdlib import *
from esper.prelude import *
import django.apps

ESPER_ENV = os.environ.get('ESPER_ENV')
BUCKET = os.environ.get('BUCKET')
DATA_PATH = os.environ.get('DATA_PATH')

if ESPER_ENV == 'google':
    storage_config = StorageConfig.make_gcs_config(BUCKET)
else:
    storage_config = StorageConfig.make_posix_config()
storage = StorageBackend.make_from_config(storage_config)


# Prints and flushes (necessary for gunicorn logs)
def _print(*args):
    pprint((*args))
    sys.stdout.flush()


# Renders home page
def index(request):
    return render(request, 'index.html',
                  {'globals': json.dumps(esper_js_globals())})


# Run search routine