diff globalneighbors/web.py @ 20:2fef925fbf37

display country + population in autocomplete drop down
author Jeff Hammel <k0scist@gmail.com>
date Sun, 25 Jun 2017 16:12:08 -0700
parents 21095c9006e5
children e69cb496324e
line wrap: on
line diff
--- a/globalneighbors/web.py	Sun Jun 25 15:43:45 2017 -0700
+++ b/globalneighbors/web.py	Sun Jun 25 16:12:08 2017 -0700
@@ -16,6 +16,7 @@
 from wsgiref import simple_server
 from .locations import locations
 from .locations import city_dict
+from .neighbors import read_neighbors_file
 from .read import read_cities
 from .read import read_city_list
 from .schema import fields
@@ -113,7 +114,10 @@
 
     content_type = 'text/html'
 
-    def __init__(self, datafile, template_dir=template_dir):
+    def __init__(self,
+                 datafile,
+                 neighbors_file=None,
+                 template_dir=template_dir):
 
 
         # parse data
@@ -121,6 +125,8 @@
         self.cities = read_city_list(self.datafile,
                                      fields=fields)
         self.locations = locations(self.cities)
+        if neighbors_file:
+            pass  # TODO
 
         # get country codes
         self.country_codes = sorted(set([city['country code']
@@ -180,10 +186,13 @@
     parser.add_argument('--hostname', dest='hostname',
                         default='localhost',
                         help="host name [DEFAULT: %(default)s]")
+    parser.add_argument('--neighbors', dest='neighbors_file',
+                        help="file for nearest neighbors")
     options = parser.parse_args(args)
 
     # instantiate WSGI handler
-    app = GlobalHandler(datafile=options.cities)
+    app = GlobalHandler(datafile=options.cities,
+                        neighbors_file=options.neighbors_file)
 
     # wrap it in a static file server
     app = PassthroughFileserver(app)