view wsgiapp.py @ 23:6891c5523b69

load with neighbors :)
author Jeff Hammel <k0scist@gmail.com>
date Sun, 25 Jun 2017 18:13:43 -0700
parents 811adc9736eb
children
line wrap: on
line source

"""
WSGI app as appropriate for gunicorn
"""

import os
import sys
from globalneighbors.web import GlobalHandler
from globalneighbors.web import PassthroughFileserver

# paths
here = os.path.dirname(os.path.abspath(__file__))
print ("You are here: {}".format(here))
cities1000 = os.environ.get("CITIES1000")
if not cities1000:
    # XXX use a default not really appropriate for production
    cities1000 = os.path.join(here, 'tests', 'data', 'cities1000.txt')
assert os.path.exists(cities1000)
neighbors = '/home/jhammel/GlobalNeighbors/neighbors.dat'
assert os.path.exists(neighbors)

# WSGI App
application = PassthroughFileserver(GlobalHandler(cities1000,
                                                  neighbors_file=neighbors))
print ("Finished loading application")
sys.stdout.flush()