From a76b7214be9f4feda7ac0cd2b16814e62dd3e479 Mon Sep 17 00:00:00 2001 From: Wolfgang Fahl Date: Fri, 24 Feb 2023 05:59:19 +0000 Subject: [PATCH] improves jpdemo for server usage --- pyproject.toml | 1 + scripts/jpdemo | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0e62147e..c02ae29a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,7 @@ test = [ #pandas_datareader", #example "plotly", # example "pydeck", # example + "pydevd", # demo_browser "pygments", # demo_browser "seaborn", # example #scipy", # example diff --git a/scripts/jpdemo b/scripts/jpdemo index c1689ac0..d3fe4c3f 100755 --- a/scripts/jpdemo +++ b/scripts/jpdemo @@ -1,9 +1,16 @@ #!/bin/bash # WF 2022-10-23 +python -m venv --upgrade-deps venv +source venv/bin/activate +pip install '.[test]' + export PYTHONPATH=. host=$(hostname -f) port=8099 +# +# start the webbrowser +# webbrowser() { local l_sleeptime=$1 local l_host=$2 @@ -11,6 +18,36 @@ webbrowser() { sleep $l_sleeptime open http://$l_host:$l_port } -echo "Starting justpy demo browser on host $host port $port ..." -webbrowser 1 $host $port& -python examples/demo_browser.py --port $port --host $host + +# show usage +# +usage() { + echo "$0 [-h|--help]" + echo "-s |--server: start justpy demo server" + echo "-b |--browser: start local demo browser" + echo "-h |--help: show this usage" + exit 1 +} + +if [ $# -lt 1 ] +then + usage +else + while [ "$1" != "" ] + do + option="$1" + case $option in + -h|--help) + usage + ;; + -s|--serve) + echo "Starting justpy demo browser on host $host port $port ..." + python examples/demo_browser.py --port $port --host $host + ;; + -b|--browse) + webbrowser 1 $host $port& + ;; + esac + shift + done +fi