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 from build import trace_viewer_project
12 def do_GET_json_examples(request):
14 for dirpath, dirnames, filenames in os.walk(test_data_path):
19 files_as_json = json.dumps(data_files)
21 request.send_response(200)
22 request.send_header('Content-Type', 'application/json')
23 request.send_header('Content-Length', len(files_as_json))
25 request.wfile.write(files_as_json)
27 def do_GET_json_examples_skp(request):
29 for dirpath, dirnames, filenames in os.walk(skp_data_path):
34 files_as_json = json.dumps(data_files)
36 request.send_response(200)
37 request.send_header('Content-Type', 'application/json')
38 request.send_header('Content-Length', len(files_as_json))
40 request.wfile.write(files_as_json)
43 project = trace_viewer_project.TraceViewerProject()
45 server = tvcm.DevServer(port=port, project=project)
46 server.AddPathHandler('/json/examples', do_GET_json_examples)
47 server.AddPathHandler('/json/examples/skp', do_GET_json_examples_skp)
49 server.AddSourcePathMapping(project.trace_viewer_path)
50 server.AddTestLink('/examples/skia_debugger.html', 'Skia Debugger')
51 server.AddTestLink('/examples/trace_viewer.html', 'Trace File Viewer')
52 server.serve_forever()
54 if __name__ == '__main__':
55 sys.exit(Main(port=8003, args=sys.argv[1:]))