blob: af6ea4376bae9597dcaec9ee232312ba2974bb7b [file] [log] [blame]
code='''
import ease_init
ease_init.connect_to_ease()
'''
#TODO : manage to use this kind of code to terminate the server when the tab is closed in the browser
code2 ='''from IPython.display import Javascript
Javascript(\'\'\'
window.addEventListener('beforeunload', function() {
require(['base/js/utils'], function(utils){
utils.ajax(utils.url_path_join(
utils.get_body_data("baseUrl"),
"api",
"shutdown"),
{
type: "POST",
}
);
}
);
});
window.onbeforeunload = function () {
require(['base/js/utils'], function(utils){
utils.ajax(utils.url_path_join(
utils.get_body_data("baseUrl"),
"api",
"shutdown"
), {
type: "POST",
});
});
}
\'\'\')'''
if __name__ == '__main__':
from ipykernel.kernelapp import IPKernelApp
import sys
if sys.path[0] == '':
del sys.path[0]
app = IPKernelApp.instance()
app.initialize(None)
result = app.kernel.do_execute(code, silent=True)
#result = app.kernel.do_execute(code2, silent=True)
app.start()