Skip to content

Commit

Permalink
make token available through CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
PythonFZ committed Oct 4, 2023
1 parent 80fa0cc commit b95df17
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion zndraw/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
def index():
"""Render the main ZnDraw page."""
if "uuid" not in session:
session["uuid"] = str(uuid.uuid4())
session["uuid"] = app.config.get("uuid", str(uuid.uuid4()))

kwargs = {
"url": request.url_root,
Expand Down
5 changes: 5 additions & 0 deletions zndraw/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def main(
hidden=True,
help="Set the html attribute upgrade-insecure-requests. If you are running ZnDraw behind a reverse proxy and encounter issues with insecure requests, you might want to set this to true.",
),
use_token: bool = typer.Option(
False,
help="Use a token to authenticate the ZnDraw server. This is useful if you are running ZnDraw as a server application.",
),
):
"""Start the ZnDraw server.
Expand All @@ -77,4 +81,5 @@ def main(
compute_bonds=compute_bonds,
multiprocessing=multiprocessing,
upgrade_insecure_requests=upgrade_insecure_requests,
use_token=use_token,
)
3 changes: 3 additions & 0 deletions zndraw/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ def view(
step: int,
compute_bonds: bool,
multiprocessing: bool,
use_token: bool = False,
upgrade_insecure_requests: bool = False,
):
if filename is not None:
app.config["filename"] = filename
app.config["start"] = start
app.config["stop"] = stop
app.config["step"] = step
if not use_token:
app.config["uuid"] = "default"
app.config["upgrade_insecure_requests"] = upgrade_insecure_requests
app.config["compute_bonds"] = compute_bonds
app.config["multiprocessing"] = multiprocessing
Expand Down
2 changes: 1 addition & 1 deletion zndraw/zndraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ZnDraw(collections.abc.MutableSequence):
)
file: FileIO = None
wait: bool = False
token: str = None
token: str = "default"

display_new: bool = True
_retries: int = 5
Expand Down

0 comments on commit b95df17

Please sign in to comment.