Open the webserver URL in the default browser
This commit is contained in:
parent
26a0f86786
commit
1da451dff5
20
dev.sh
20
dev.sh
|
@ -40,6 +40,22 @@ _setup () {
|
||||||
overmind quit
|
overmind quit
|
||||||
sleep 2
|
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
|
# Main tasks start
|
||||||
|
@ -49,9 +65,11 @@ declare -A descriptions
|
||||||
run () {
|
run () {
|
||||||
_setup
|
_setup
|
||||||
find . -name __pycache__ -o -name "*.pyc" -delete
|
find . -name __pycache__ -o -name "*.pyc" -delete
|
||||||
|
url=$(_create_url)
|
||||||
sudo iptables -I INPUT -p tcp --dport $WEBPORT -j ACCEPT
|
sudo iptables -I INPUT -p tcp --dport $WEBPORT -j ACCEPT
|
||||||
printf "\n---\n webserver: http://$(hostname -f):$WEBPORT\n---\n"
|
|
||||||
overmind start -D
|
overmind start -D
|
||||||
|
printf "\n---\n webserver: $url\n---\n"
|
||||||
|
_open_url $url
|
||||||
}
|
}
|
||||||
descriptions["run"]="Start the webserver."
|
descriptions["run"]="Start the webserver."
|
||||||
tasks["run"]=run
|
tasks["run"]=run
|
||||||
|
|
Loading…
Reference in New Issue