comparison globalneighbors/web.py @ 11:d1b99c695511

remove obselete data
author Jeff Hammel <k0scist@gmail.com>
date Sun, 25 Jun 2017 12:54:05 -0700
parents 21ed15391e8a
children 94af113e498a
comparison
equal deleted inserted replaced
10:21ed15391e8a 11:d1b99c695511
8 import argparse 8 import argparse
9 import json 9 import json
10 import os 10 import os
11 import sys 11 import sys
12 import time 12 import time
13 from paste import httpserver
14 from paste.urlparser import StaticURLParser
13 from webob import Request, Response, exc 15 from webob import Request, Response, exc
14 from wsgiref import simple_server 16 from wsgiref import simple_server
15 from .locations import locations 17 from .locations import locations
16 from .locations import city_dict 18 from .locations import city_dict
17 from .read import read_cities 19 from .read import read_cities
161 options = parser.parse_args(args) 163 options = parser.parse_args(args)
162 164
163 # instantiate WSGI handler 165 # instantiate WSGI handler
164 app = GlobalHandler(datafile=options.cities) 166 app = GlobalHandler(datafile=options.cities)
165 167
166 # serve it (Warning! Single threaded!) 168 # wrap it in a static file server
167 server = simple_server.make_server(host='0.0.0.0', 169 app = PassthroughFileserver(app)
168 port=options.port, 170
169 app=app) 171 print ("Serving on http://{hostname}:{port}/".format(**options.__dict__))
170 try: 172 try:
171 print ("Serving on http://{hostname}:{port}/".format(**options.__dict__)) 173 httpserver.serve(app, host='0.0.0.0', port=options.port)
172 server.serve_forever()
173 except KeyboardInterrupt: 174 except KeyboardInterrupt:
174 pass 175 pass
175 176
176 177
177 if __name__ == '__main__': 178 if __name__ == '__main__':
178 main() 179 main()
179