##// END OF EJS Templates
Made open_in_browser configurable.
damianavila -
Show More
@@ -19,7 +19,7 b' import webbrowser'
19 from BaseHTTPServer import HTTPServer
19 from BaseHTTPServer import HTTPServer
20 from SimpleHTTPServer import SimpleHTTPRequestHandler
20 from SimpleHTTPServer import SimpleHTTPRequestHandler
21
21
22 from IPython.utils.traitlets import Unicode
22 from IPython.utils.traitlets import Unicode, Bool
23
23
24 from .base import PostProcessorBase
24 from .base import PostProcessorBase
25
25
@@ -34,6 +34,10 b' class ServePostProcessor(PostProcessorBase):'
34 help="""Directory to write output to. Leave blank
34 help="""Directory to write output to. Leave blank
35 to output to the current directory""")
35 to output to the current directory""")
36
36
37 open_in_browser = Bool(True, config=True,
38 help="""Set to False to deactivate
39 the opening of the browser""")
40
37 def call(self, input):
41 def call(self, input):
38 """
42 """
39 Simple implementation to serve the build directory.
43 Simple implementation to serve the build directory.
@@ -45,6 +49,7 b' class ServePostProcessor(PostProcessorBase):'
45 sa = httpd.socket.getsockname()
49 sa = httpd.socket.getsockname()
46 name = input[2:]
50 name = input[2:]
47 url = "http://" + sa[0] + ":" + str(sa[1]) + "/" + name
51 url = "http://" + sa[0] + ":" + str(sa[1]) + "/" + name
52 if self.open_in_browser:
48 webbrowser.open(url, new=2)
53 webbrowser.open(url, new=2)
49 print("Serving " + name + " on " + url)
54 print("Serving " + name + " on " + url)
50 print("Use Control-C to stop this server.")
55 print("Use Control-C to stop this server.")
General Comments 0
You need to be logged in to leave comments. Login now