2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
9 import build # Brings in tvcm bindings.
12 toplevel_path = os.path.abspath(os.path.dirname(__file__))
13 src_path = os.path.join(toplevel_path, 'src')
14 test_data_path = os.path.join(toplevel_path, 'test_data')
15 skp_data_path = os.path.join(toplevel_path, 'skp_data')
17 def do_GET_json_examples(request):
19 for dirpath, dirnames, filenames in os.walk(test_data_path):
24 files_as_json = json.dumps(data_files)
26 request.send_response(200)
27 request.send_header('Content-Type', 'application/json')
28 request.send_header('Content-Length', len(files_as_json))
30 request.wfile.write(files_as_json)
32 def do_GET_json_examples_skp(request):
34 for dirpath, dirnames, filenames in os.walk(skp_data_path):
39 files_as_json = json.dumps(data_files)
41 request.send_response(200)
42 request.send_header('Content-Type', 'application/json')
43 request.send_header('Content-Length', len(files_as_json))
45 request.wfile.write(files_as_json)
48 server = tvcm.DevServer(port=port)
49 server.AddPathHandler('/json/examples', do_GET_json_examples)
50 server.AddPathHandler('/json/examples/skp', do_GET_json_examples_skp)
52 server.AddSourcePathMapping('/src', src_path)
53 server.AddDataPathMapping('/third_party', os.path.join(toplevel_path, 'third_party'))
54 server.AddDataPathMapping('/examples', os.path.join(toplevel_path, 'examples'))
55 server.AddDataPathMapping('/test_data', test_data_path)
56 server.AddDataPathMapping('/skp_data', skp_data_path)
57 server.serve_forever()
59 if __name__ == '__main__':
60 sys.exit(Main(port=8003, args=sys.argv[1:]))