Open the webserver URL in the default browser

This commit is contained in:
Andreas Zweili 2023-08-03 11:12:35 +02:00
parent 26a0f86786
commit 1da451dff5
1 changed files with 19 additions and 1 deletions

20
dev.sh
View File

@ -40,6 +40,22 @@ _setup () {
overmind quit
sleep 2
}
_open_url () {
if [[ ! -z "${DEFAULT_BROWSER}" ]]; then
$DEFAULT_BROWSER $url
elif type explorer.exe &> /dev/null; then
explorer.exe $url
fi
}
_create_url () {
if [ -f /etc/wsl.conf ]; then
echo "http://localhost:$WEBPORT"
else
echo "http://$(hostname -f):$WEBPORT"
fi
}
#}
# Main tasks start
@ -49,9 +65,11 @@ declare -A descriptions
run () {
_setup
find . -name __pycache__ -o -name "*.pyc" -delete
url=$(_create_url)
sudo iptables -I INPUT -p tcp --dport $WEBPORT -j ACCEPT
printf "\n---\n webserver: http://$(hostname -f):$WEBPORT\n---\n"
overmind start -D
printf "\n---\n webserver: $url\n---\n"
_open_url $url
}
descriptions["run"]="Start the webserver."
tasks["run"]=run