annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 """
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2 WSGI app as appropriate for gunicorn
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 import os
19
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
6 import sys
0
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 from globalneighbors.web import GlobalHandler
19
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
8 from globalneighbors.web import PassthroughFileserver
0
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 # paths
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 here = os.path.dirname(os.path.abspath(__file__))
19
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
12 print ("You are here: {}".format(here))
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
13 cities1000 = os.environ.get("CITIES1000")
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
14 if not cities1000:
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
15 # XXX use a default not really appropriate for production
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
16 cities1000 = os.path.join(here, 'tests', 'data', 'cities1000.txt')
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
17 assert os.path.exists(cities1000)
0
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 # WSGI App
19
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
20 application = PassthroughFileserver(GlobalHandler(cities1000))
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
21 print ("Finished loading application")
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
22 sys.stdout.flush()