##// END OF EJS Templates
change default behavior of database task storage...
change default behavior of database task storage The previous default behavior was to create a new table (sqlite) / database (mongodb) for each Hub instance, so that task history would not be shared by subsequent IPython sessions. I don't think this was the right choice, so this PR switches the default behavior to use the table / database `ipython-tasks`. The result is that all Hub sessions in a given profile will share history by default, which makes the benefit of the db backends clearer. Configurable behavior remains the same, only the default is changed.

File last commit:

r12218:19e43d9d
r12255:8683a413
Show More
serve.py
55 lines | 1.9 KiB | text/x-python | PythonLexer
"""
Contains postprocessor for serving nbconvert output.
"""
#-----------------------------------------------------------------------------
#Copyright (c) 2013, the IPython Development Team.
#
#Distributed under the terms of the Modified BSD License.
#
#The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import os
import webbrowser
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
from IPython.utils.traitlets import Bool
from .base import PostProcessorBase
#-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
class ServePostProcessor(PostProcessorBase):
"""Post processor designed to serve files"""
open_in_browser = Bool(True, config=True,
help="""Set to False to deactivate
the opening of the browser""")
def postprocess(self, input):
"""
Simple implementation to serve the build directory.
"""
try:
dirname, filename = os.path.split(input)
if dirname:
os.chdir(dirname)
httpd = HTTPServer(('127.0.0.1', 8000), SimpleHTTPRequestHandler)
sa = httpd.socket.getsockname()
url = "http://" + sa[0] + ":" + str(sa[1]) + "/" + filename
if self.open_in_browser:
webbrowser.open(url, new=2)
print("Serving your slides on " + url)
print("Use Control-C to stop this server.")
httpd.serve_forever()
except KeyboardInterrupt:
print("The server is shut down.")