annotate wsgiapp.py @ 24:40a9850076a4

[documentation] links
author Jeff Hammel <k0scist@gmail.com>
date Mon, 04 Sep 2017 14:54:38 -0700
parents 6891c5523b69
children
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)
23
6891c5523b69 load with neighbors :)
Jeff Hammel <k0scist@gmail.com>
parents: 19
diff changeset
18 neighbors = '/home/jhammel/GlobalNeighbors/neighbors.dat'
6891c5523b69 load with neighbors :)
Jeff Hammel <k0scist@gmail.com>
parents: 19
diff changeset
19 assert os.path.exists(neighbors)
0
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20
5dba84370182 initial commit; half-working prototype
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 # WSGI App
23
6891c5523b69 load with neighbors :)
Jeff Hammel <k0scist@gmail.com>
parents: 19
diff changeset
22 application = PassthroughFileserver(GlobalHandler(cities1000,
6891c5523b69 load with neighbors :)
Jeff Hammel <k0scist@gmail.com>
parents: 19
diff changeset
23 neighbors_file=neighbors))
19
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
24 print ("Finished loading application")
811adc9736eb add configuration for gunicorn
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
25 sys.stdout.flush()