OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import argparse | 6 import argparse |
7 import cherrypy | 7 import cherrypy |
8 import json | 8 import json |
9 import os | 9 import os |
10 import staticdirindex | 10 import staticdirindex |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 def main(): | 38 def main(): |
39 parser = argparse.ArgumentParser(description='Sky development server') | 39 parser = argparse.ArgumentParser(description='Sky development server') |
40 parser.add_argument('-v', '--verbose', action='store_true', | 40 parser.add_argument('-v', '--verbose', action='store_true', |
41 help='Enable logging to the console.') | 41 help='Enable logging to the console.') |
42 parser.add_argument('app_path', type=str) | 42 parser.add_argument('app_path', type=str) |
43 parser.add_argument('port', type=int) | 43 parser.add_argument('port', type=int) |
44 args = parser.parse_args() | 44 args = parser.parse_args() |
45 | 45 |
46 log_dir = os.path.abspath(os.getcwd()) | 46 log_dir = os.path.abspath(os.getcwd()) |
47 print "%s logging to access_log.txt in %s" % ( | |
48 parser.prog, log_dir) | |
49 | 47 |
50 config = { | 48 config = { |
51 'global': { | 49 'global': { |
52 'server.socket_port': args.port, | 50 'server.socket_port': args.port, |
| 51 'tools.staticdir.content_types' : { |
| 52 'sky': 'text/sky', |
| 53 }, |
53 'log.screen': args.verbose, | 54 'log.screen': args.verbose, |
54 'log.access_log': os.path.join(log_dir, 'access_log.txt'), | 55 'log.access_log': os.path.join(log_dir, 'access_log.txt'), |
55 # This causes some strange python exception?? | 56 # This causes some strange python exception?? |
56 # 'log.error_log': os.path.join(log_dir, 'error_log.txt'), | 57 # 'log.error_log': os.path.join(log_dir, 'error_log.txt'), |
57 }, | 58 }, |
58 '/': { | 59 '/': { |
59 'tools.staticdir.on': True, | 60 'tools.staticdir.on': True, |
60 'tools.staticdir.dir': os.path.abspath(args.app_path), | 61 'tools.staticdir.dir': os.path.abspath(args.app_path), |
61 'tools.staticdir.indexlister': skydir, | 62 'tools.staticdir.indexlister': skydir, |
62 }, | 63 }, |
63 '/mojo/public': { | 64 '/mojo/public': { |
64 'tools.staticdir.on': True, | 65 'tools.staticdir.on': True, |
65 'tools.staticdir.dir': os.path.join(GEN_ROOT, 'mojo', 'public'), | 66 'tools.staticdir.dir': os.path.join(GEN_ROOT, 'mojo', 'public'), |
66 }, | 67 }, |
67 '/mojo/services': { | 68 '/mojo/services': { |
68 'tools.staticdir.on': True, | 69 'tools.staticdir.on': True, |
69 'tools.staticdir.dir': os.path.join(GEN_ROOT, 'mojo', 'services'), | 70 'tools.staticdir.dir': os.path.join(GEN_ROOT, 'mojo', 'services'), |
70 }, | 71 }, |
71 '/sky/services': { | 72 '/sky/services': { |
72 'tools.staticdir.on': True, | 73 'tools.staticdir.on': True, |
73 'tools.staticdir.dir': os.path.join(GEN_ROOT, 'sky', 'services'), | 74 'tools.staticdir.dir': os.path.join(GEN_ROOT, 'sky', 'services'), |
74 }, | 75 }, |
75 } | 76 } |
76 cherrypy.quickstart(config=config) | 77 cherrypy.quickstart(config=config) |
77 | 78 |
78 | 79 |
79 if __name__ == '__main__': | 80 if __name__ == '__main__': |
80 main() | 81 main() |
OLD | NEW |