forked from htmlpreview/htmlpreview.github.com
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathserve
executable file
·41 lines (33 loc) · 830 Bytes
/
serve
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env sh
# SPDX-FileCopyrightText: 2024 Robin Vobruba <hoijui.quaero@gmail.com>
# SPDX-License-Identifier: Unlicense
set -eu
script_path="$(readlink -f "$0")"
script_dir="$(dirname "$script_path")"
script_name="$(basename "$script_path")"
serve_port="8083"
# serve_dir="$script_dir/../public/"
serve_dir="$script_dir/../"
print_help() {
echo "$script_name - Runs a simple HTTP server,"
echo "serving '$serve_dir' on <http://localhost:8083>."
}
# read command-line args
i=1
while [ "$i" -lt "$#" ]
do
arg="$(eval "echo \$$i")"
case "$arg" in
-h|--help)
shift "$i"
print_help
exit 0
;;
*) # non-/unknown option
i=$((i + 1))
;;
esac
done
echo "Serving '$serve_dir' on <http://localhost:$serve_port>."
echo "Stop serving with [Ctrl+C]."
busybox httpd -f -h "$serve_dir" -v -p "$serve_port"