diff wsgiapp.py @ 19:811adc9736eb

add configuration for gunicorn
author Jeff Hammel <k0scist@gmail.com>
date Sun, 25 Jun 2017 15:43:45 -0700
parents 5dba84370182
children 6891c5523b69
line wrap: on
line diff
--- a/wsgiapp.py	Sun Jun 25 15:13:29 2017 -0700
+++ b/wsgiapp.py	Sun Jun 25 15:43:45 2017 -0700
@@ -3,12 +3,20 @@
 """
 
 import os
+import sys
 from globalneighbors.web import GlobalHandler
+from globalneighbors.web import PassthroughFileserver
 
 # paths
 here = os.path.dirname(os.path.abspath(__file__))
-data = os.path.join(here, 'data')
-cities1000 = os.path.join(data, 'cities1000.txt')
+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)
 
 # WSGI App
-app  = GlobalHandler(cities1000)
+application = PassthroughFileserver(GlobalHandler(cities1000))
+print ("Finished loading application")
+sys.stdout.flush()