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 | |||
@@ -33,6 +33,10 b' class ServePostProcessor(PostProcessorBase):' | |||||
33 | build_directory = Unicode(".", config=True, |
|
33 | build_directory = Unicode(".", config=True, | |
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 | ||||
|
37 | open_in_browser = Bool(True, config=True, | |||
|
38 | help="""Set to False to deactivate | |||
|
39 | the opening of the browser""") | |||
36 |
|
40 | |||
37 | def call(self, input): |
|
41 | def call(self, input): | |
38 | """ |
|
42 | """ | |
@@ -45,7 +49,8 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 | |
48 | webbrowser.open(url, new=2) |
|
52 | if self.open_in_browser: | |
|
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.") | |
51 | httpd.serve_forever() |
|
56 | httpd.serve_forever() |
General Comments 0
You need to be logged in to leave comments.
Login now