Add a sky_server for running sky apps
This automatically adds /sky and /mojo mappings to the generated files for each. Also taught skydb to use this new server. R=esprehn@chromium.org, abarth@chromium.org Review URL: https://codereview.chromium.org/682153003
This commit is contained in:
parent
86650b9310
commit
eb07773150
46
engine/src/flutter/tools/sky_server
Executable file
46
engine/src/flutter/tools/sky_server
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import cherrypy
|
||||
|
||||
BUILD_DIRECTORY = 'out'
|
||||
CONFIG_DIRECTORY = 'Debug'
|
||||
GEN_DIRECTORY = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir,
|
||||
os.pardir, BUILD_DIRECTORY, CONFIG_DIRECTORY, 'gen'))
|
||||
|
||||
# FIXME: This doesn't yet support directory listings. We'll do something like:
|
||||
# http://tools.cherrypy.org/wiki/staticdirindex
|
||||
# but have it spit .sky instead of HTML
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Sky development server')
|
||||
parser.add_argument('app_path', type=str)
|
||||
parser.add_argument('port', type=int)
|
||||
args = parser.parse_args()
|
||||
|
||||
config = {
|
||||
'global': {
|
||||
'server.socket_port': args.port,
|
||||
},
|
||||
'/': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': os.path.abspath(args.app_path),
|
||||
},
|
||||
'/sky': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': os.path.join(GEN_DIRECTORY, 'sky'),
|
||||
},
|
||||
'/mojo': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': os.path.join(GEN_DIRECTORY, 'mojo'),
|
||||
}
|
||||
}
|
||||
cherrypy.quickstart(config=config)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -12,7 +12,8 @@ import urlparse
|
||||
|
||||
BUILD_DIRECTORY = 'out'
|
||||
CONFIG_DIRECTORY = 'Debug'
|
||||
MOJO_SHELL_PATH = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir,
|
||||
SKY_TOOLS_DIRECTORY = os.path.abspath(os.path.join(__file__, os.pardir))
|
||||
MOJO_SHELL_PATH = os.path.abspath(os.path.join(SKY_TOOLS_DIRECTORY, os.pardir,
|
||||
os.pardir, BUILD_DIRECTORY, CONFIG_DIRECTORY, 'mojo_shell'))
|
||||
|
||||
SUPPORTED_MIME_TYPES = [
|
||||
@ -23,14 +24,12 @@ SUPPORTED_MIME_TYPES = [
|
||||
|
||||
def start_http_server_for_file(path):
|
||||
HTTP_PORT = 9999
|
||||
directory = os.path.dirname(os.path.abspath(path))
|
||||
server_command = [
|
||||
'python',
|
||||
'-m',
|
||||
'SimpleHTTPServer',
|
||||
str(HTTP_PORT)
|
||||
os.path.join(SKY_TOOLS_DIRECTORY, 'sky_server'),
|
||||
os.path.dirname(os.path.abspath(path)),
|
||||
str(HTTP_PORT),
|
||||
]
|
||||
subprocess.Popen(server_command, cwd=directory)
|
||||
subprocess.Popen(server_command)
|
||||
return 'http://localhost:%s/%s' % (HTTP_PORT, os.path.basename(path))
|
||||
|
||||
|
||||
@ -64,4 +63,7 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
print "Quitting"
|
||||
|
Loading…
x
Reference in New Issue
Block a user