mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-12 04:23:01 +00:00
make multiuser_notebook a package
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
node_modules
|
||||
*.pyx
|
||||
*.py[co]
|
||||
*~
|
||||
.DS_Store
|
||||
|
@@ -24,7 +24,7 @@ Basic principals:
|
||||
|
||||
## to use
|
||||
|
||||
$> python multiuser.py
|
||||
$> python -m multiuser_notebook
|
||||
|
||||
visit `http://localhost:8000`, and login (any username, password=`password`).
|
||||
|
||||
|
0
multiuser_notebook/__init__.py
Normal file
0
multiuser_notebook/__init__.py
Normal file
2
multiuser_notebook/__main__.py
Normal file
2
multiuser_notebook/__main__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .multiuser import main
|
||||
main()
|
16
multiuser_notebook/headers.py
Normal file
16
multiuser_notebook/headers.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import json
|
||||
|
||||
from tornado import web
|
||||
from tornado.escape import xhtml_escape
|
||||
|
||||
class HeadersHandler(web.RequestHandler):
|
||||
def get(self):
|
||||
headers = {}
|
||||
for key, value in self.request.headers.items():
|
||||
if ';' in value:
|
||||
value = [ s.strip() for s in value.split(';') ]
|
||||
headers[key] = value
|
||||
self.write("<pre>%s</pre>" % (
|
||||
xhtml_escape(json.dumps(headers, indent=1))
|
||||
))
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var ConfigurableProxy = require('./lib/configproxy.js').ConfigurableProxy;
|
||||
var ConfigurableProxy = require('./configproxy.js').ConfigurableProxy;
|
||||
|
||||
var proxy = new ConfigurableProxy();
|
||||
proxy.listen(8000);
|
@@ -25,7 +25,7 @@ from tornado.options import define, options
|
||||
from IPython.utils.traitlets import HasTraits, Any, Unicode, Integer, Dict
|
||||
from IPython.html import utils
|
||||
|
||||
from headers import HeadersHandler
|
||||
from .headers import HeadersHandler
|
||||
|
||||
def random_port():
|
||||
"""get a single random port"""
|
||||
@@ -37,6 +37,8 @@ def random_port():
|
||||
|
||||
auth_header_pat = re.compile(r'^token\s+([^\s]+)$')
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
|
||||
def token_authorized(method):
|
||||
def check_token(self, *args, **kwargs):
|
||||
auth_header = self.request.headers.get('Authorization', '')
|
||||
@@ -96,7 +98,7 @@ class UserSession(HasTraits):
|
||||
|
||||
def start(self):
|
||||
assert self.process is None or self.process.poll() is not None
|
||||
cmd = [sys.executable, 'singleuser.py',
|
||||
cmd = [sys.executable, '-m', 'multiuser_notebook.singleuser',
|
||||
'--user=%s' % self.user, '--port=%i' % self.port,
|
||||
'--cookie-name=%s' % self.cookie_name,
|
||||
'--multiuser-prefix=%s' % self.multiuser_prefix,
|
||||
@@ -338,10 +340,11 @@ def main():
|
||||
'api',
|
||||
),
|
||||
login_url=utils.url_path_join(base_url, 'login'),
|
||||
template_path=os.path.join(here, 'templates'),
|
||||
)
|
||||
http_server = tornado.httpserver.HTTPServer(application)
|
||||
http_server.listen(options.port)
|
||||
proxy = Popen(["node", "proxy.js"])
|
||||
proxy = Popen(["node", os.path.join(here, 'js', 'main.js')])
|
||||
try:
|
||||
tornado.ioloop.IOLoop.instance().start()
|
||||
finally:
|
@@ -18,7 +18,9 @@ from tornado.options import define, options
|
||||
|
||||
from IPython.html import utils
|
||||
|
||||
from headers import HeadersHandler
|
||||
from .headers import HeadersHandler
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
|
||||
class BaseHandler(RequestHandler):
|
||||
@property
|
Reference in New Issue
Block a user