Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
flowengine-docker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template
flowengine-docker
Commits
320ae5db
Commit
320ae5db
authored
Nov 08, 2023
by
marwan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add jupyter-config.py
parent
6a4c5108
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
jupyter-config.py
+63
-0
No files found.
jupyter-config.py
0 → 100644
View file @
320ae5db
import
os
import
stat
import
subprocess
from
pathlib
import
Path
from
jupyter_core.paths
import
jupyter_data_dir
c
=
get_config
()
# noqa: F821
c
.
ServerApp
.
ip
=
"0.0.0.0"
c
.
ServerApp
.
open_browser
=
False
# to output both image/svg+xml and application/pdf plot formats in the notebook file
c
.
InlineBackend
.
figure_formats
=
{
"png"
,
"jpeg"
,
"svg"
,
"pdf"
}
# https://github.com/jupyter/notebook/issues/3130
c
.
FileContentsManager
.
delete_to_trash
=
False
# Generate a self-signed certificate
OPENSSL_CONFIG
=
"""
\
[req]
distinguished_name = req_distinguished_name
[req_distinguished_name]
"""
if
"GEN_CERT"
in
os
.
environ
:
dir_name
=
Path
(
jupyter_data_dir
())
dir_name
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
pem_file
=
dir_name
/
"notebook.pem"
# Generate an openssl.cnf file to set the distinguished name
cnf_file
=
Path
(
os
.
getenv
(
"CONDA_DIR"
,
"/usr/lib"
))
/
"ssl/openssl.cnf"
if
not
cnf_file
.
exists
():
cnf_file
.
write_text
(
OPENSSL_CONFIG
)
# Generate a certificate if one doesn't exist on disk
subprocess
.
check_call
(
[
"openssl"
,
"req"
,
"-new"
,
"-newkey=rsa:2048"
,
"-days=365"
,
"-nodes"
,
"-x509"
,
"-subj=/C=XX/ST=XX/L=XX/O=generated/CN=generated"
,
f
"-keyout={pem_file}"
,
f
"-out={pem_file}"
,
]
)
# Restrict access to the file
pem_file
.
chmod
(
stat
.
S_IRUSR
|
stat
.
S_IWUSR
)
c
.
ServerApp
.
certfile
=
str
(
pem_file
)
# Change default umask for all subprocesses of the Server if set in the environment
if
"NB_UMASK"
in
os
.
environ
:
os
.
umask
(
int
(
os
.
environ
[
"NB_UMASK"
],
8
))
DESTINATION_EMBED
=
os
.
environ
[
'JUPYTER_CUS_DESTINATION_EMBED'
]
c
.
NotebookApp
.
tornado_settings
=
{
'headers'
:
{
'Content-Security-Policy'
:
"frame-ancestors "
+
DESTINATION_EMBED
+
" 'self' "
,
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment