Show More
@@ -19,7 +19,7 b' import webbrowser' | |||
|
19 | 19 | from BaseHTTPServer import HTTPServer |
|
20 | 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 | 24 | from .base import PostProcessorBase |
|
25 | 25 | |
@@ -33,6 +33,10 b' class ServePostProcessor(PostProcessorBase):' | |||
|
33 | 33 | build_directory = Unicode(".", config=True, |
|
34 | 34 | help="""Directory to write output to. Leave blank |
|
35 | 35 | to output to the current directory""") |
|
36 | ||
|
37 | open_in_browser = Bool(True, config=True, | |
|
38 | help="""Set to False to deactivate | |
|
39 | the opening of the browser""") | |
|
36 | 40 | |
|
37 | 41 | def call(self, input): |
|
38 | 42 | """ |
@@ -45,7 +49,8 b' class ServePostProcessor(PostProcessorBase):' | |||
|
45 | 49 | sa = httpd.socket.getsockname() |
|
46 | 50 | name = input[2:] |
|
47 | 51 | url = "http://" + sa[0] + ":" + str(sa[1]) + "/" + name |
|
48 | webbrowser.open(url, new=2) | |
|
52 | if self.open_in_browser: | |
|
53 | webbrowser.open(url, new=2) | |
|
49 | 54 | print("Serving " + name + " on " + url) |
|
50 | 55 | print("Use Control-C to stop this server.") |
|
51 | 56 | httpd.serve_forever() |
General Comments 0
You need to be logged in to leave comments.
Login now