forked from 4Quant/digits-docker-binder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.py
27 lines (25 loc) · 916 Bytes
/
launch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import digits, digits.webapp
import argparse
parser = argparse.ArgumentParser(description='DIGITS server')
parser.add_argument(
'-p', '--port',
type=int,
default=5000,
help='Port to run app on (default 5000)'
)
args = vars(parser.parse_args())
base_prefix = '{}proxy/{}/'.format(os.environ['JUPYTERHUB_SERVICE_PREFIX'], args['port'])
digits.webapp.app.debug = False
# binder specific code to make url_for work correctly
class FixScriptName(object):
def __init__(self, app, prefix):
self.app = app
self.prefix = prefix
def __call__(self, environ, start_response):
environ['SCRIPT_NAME'] = self.prefix
return self.app(environ, start_response)
app2 = FixScriptName(digits.webapp.app, base_prefix)
print('Launching Server', digits.webapp.app.config)
from werkzeug.serving import run_simple
run_simple('0.0.0.0', args['port'], app2, use_reloader=False)