Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print(build_dir)
rel_paths = [os.path.relpath(item, build_dir) for item in build_files]
forward_slash = [path.replace('\\', '/') for path in rel_paths]
build_escaped = [re.escape(item) for item in forward_slash]
build_strings = '|'.join(build_escaped)
static_handler_regex = "/pymedphys/({})".format(build_strings)
print(static_handler_regex)
pymedphys_handlers = [
(
ujoin(base_url, static_handler_regex),
FileFindHandler,
{'path': build_dir}
),
(
ujoin(base_url, r'/pymedphys.*'),
PyMedPhysHandler
)
]
return pymedphys_handlers
def init_webapp(self):
"""initialize tornado webapp and httpserver.
"""
super(ExampleApp, self).init_webapp()
default_handlers = [
(ujoin(self.base_url, r'notebook/(.*)?'), NotebookHandler),
(ujoin(self.base_url, r"build/(.*)"), FileFindHandler,
{'path': os.path.join(HERE, 'build')})
]
self.web_app.add_handlers('.*$', default_handlers)
def start(self):
default_handlers = [
(ujoin(self.base_url, r'/example/?'), ExampleHander),
(ujoin(self.base_url, r'/example/(.*)'), FileFindHandler, {'path': osp.join(HERE, 'build')}),
]
self.web_app.add_handlers('.*$', default_handlers)
super(ExampleApp, self).start()
assets_dir = config.assets_dir
package_file = os.path.join(assets_dir, 'package.json')
with open(package_file) as fid:
data = json.load(fid)
config.version = config.version or data['version']
config.name = config.name or data['name']
handlers = [
# TODO Redirect to /tree
(url + r'/?', NAppHandler, {'config': config, 'page': 'tree'}),
(url + r"/tree%s" % path_regex, NAppHandler, {'config': config, 'page': 'tree'}),
(url + r"/edit%s" % path_regex, NAppHandler, {'config': config, 'page': 'edit'}),
(url + r"/view%s" % path_regex, NAppHandler, {'config': config, 'page': 'view'}),
(url + r"/static/(.*)", FileFindHandler, {'path': assets_dir}),
]
web_app.add_handlers(".*$", handlers)
def start(self):
default_handlers = [
(ujoin(self.base_url, r'/example/?'), ExampleHander),
(ujoin(self.base_url, r"/example/(.*)"), FileFindHandler,
{'path': os.path.join(HERE, 'build')}),
]
self.web_app.add_handlers(".*$", default_handlers)
super(ExampleApp, self).start()
(
base(),
GraphQLHandler,
dict(
schema=graphql_manager.schema,
graphiql=graphql_manager.graphiql,
middleware=[app_middleware],
),
),
(
base("subscriptions"),
SubscriptionHandler,
dict(graphql_manager=graphql_manager),
),
# serve the graphiql assets
(base("static", "(.*)"), FileFindHandler, dict(path=[STATIC])),
],
)
app.log.debug("[graphql] initialized!")
if sys_info['commit_source'] == 'repository':
# don't cache (rely on 304) when working from master
version_hash = ''
else:
# reset the cache on server restart
version_hash = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
settings = dict(
# basics
log_function=log_request,
base_url=base_url,
default_url=default_url,
template_path=template_path,
static_path=ipython_app.static_file_path,
static_custom_path=ipython_app.static_custom_path,
static_handler_class = FileFindHandler,
static_url_prefix = url_path_join(base_url,'/static/'),
static_handler_args = {
# don't cache custom.js
'no_cache_paths': [url_path_join(base_url, 'static', 'custom')],
},
version_hash=version_hash,
# authentication
cookie_secret=ipython_app.cookie_secret,
login_url=url_path_join(base_url,'/login'),
login_handler_class=ipython_app.login_handler_class,
logout_handler_class=ipython_app.logout_handler_class,
password=ipython_app.password,
# managers
kernel_manager=kernel_manager,
def load_jupyter_server_extension(nbapp):
base_url = ujoin(nbapp.web_app.settings['base_url'], 'simplest')
handlers = [
(base_url, RedirectHandler),
(ujoin(base_url, r'tree'), AddSlashHandler),
(ujoin(base_url, r'(notebooks|tree)(.*)?'), PageHandler),
(ujoin(base_url, r"build/(.*)"), FileFindHandler,
{'path': os.path.join(HERE, 'build')})
]
nbapp.web_app.add_handlers('.*$', handlers)
def init_webapp(self):
"""initialize tornado webapp and httpserver.
"""
super(ExampleApp, self).init_webapp()
default_handlers = [
(r'/example/?', ExampleHandler),
(r"/example/(.*)", FileFindHandler,
{'path': os.path.join(HERE, 'build')}) ]
self.web_app.add_handlers('.*$', default_handlers)
def start(self):
path = os.path.join(HERE, 'build')
handlers = [
(r'/example/?', ExampleHander),
(r'/example/(.*)', FileFindHandler, {'path': path}),
]
self.web_app.add_handlers('.*$', handlers)
super(ExampleApp, self).start()