@@ -0,0 +1,2267 @@
+#!/usr/bin/env python%0A# @license%0A# Copyright 2017 Google Inc.%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#      http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0A%22%22%22%0ASimple web server serving local files that permits cross-origin requests.%0A%0AThis can be used to view local data with Neuroglancer.%0A%0AWARNING: Because this web server permits cross-origin requests, it exposes any%0Adata in the directory that is served to any web page running on a machine that%0Acan connect to the web server.%0A%22%22%22%0A%0Afrom __future__ import print_function, absolute_import%0A%0Aimport argparse%0Aimport os%0Aimport sys%0A%0Atry:%0A    # Python3 and Python2 with future package.%0A    from http.server import SimpleHTTPRequestHandler, HTTPServer%0Aexcept ImportError:%0A    from BaseHTTPServer import HTTPServer%0A    from SimpleHTTPServer import SimpleHTTPRequestHandler%0A%0A%0Aclass RequestHandler(SimpleHTTPRequestHandler):%0A    def end_headers(self):%0A        self.send_header('Access-Control-Allow-Origin', '*')%0A        SimpleHTTPRequestHandler.end_headers(self)%0A%0A%0Aclass Server(HTTPServer):%0A    protocol_version = 'HTTP/1.1'%0A%0A    def __init__(self, server_address):%0A        HTTPServer.__init__(self, server_address, RequestHandler)%0A%0A%0Aif __name__ == '__main__':%0A    ap = argparse.ArgumentParser()%0A    ap.add_argument('-p', '--port', default=9000, help='TCP port to listen on')%0A    ap.add_argument('-a', '--bind', default='127.0.0.1', help='Bind address')%0A    ap.add_argument('-d', '--directory', default='.', help='Directory to serve')%0A%0A    args = ap.parse_args()%0A    os.chdir(args.directory)%0A    server = Server((args.bind, args.port))%0A    sa = server.socket.getsockname()%0A    print(%22Serving directory %25s at http://%25s:%25d%22 %25 (os.getcwd(), sa%5B0%5D, sa%5B1%5D))%0A    try:%0A        server.serve_forever()%0A    except KeyboardInterrupt:%0A        server.server_close()%0A        sys.exit(0)%0A

Add simple web server for testing Neuroglancer with local data