share files over local network with python's http.server

This commit is contained in:
tavo-wasd 2023-10-30 10:06:55 -06:00
parent d84b397335
commit 2fabe40e9d
2 changed files with 16 additions and 1 deletions

2
.gitignore vendored
View file

@ -12,7 +12,7 @@ lutris
pcmanfm
pulse
surf/
darktable
darktable/
galculator
kalgebrarc
kdenlive-layoutsrc

15
scripts/share Executable file
View file

@ -0,0 +1,15 @@
#!/bin/sh
help() {
printf "\033[2mUsage:\033[0m share [DIRECTORY/FILE]\n"
exit 0
}
LOC="$1" ; [ -n "$LOC" ] || help
TEMP_DIR="/tmp/sharedir"
[ -d "$LOC" ] && DIR="$LOC" || DIR="$TEMP_DIR"
[ "$DIR" = "$TEMP_DIR" ] && mkdir -p "$TEMP_DIR" && cp -f "$LOC" "$DIR/"
python -m http.server -b 0.0.0.0 8000 -d "$DIR"
[ "$DIR" = "$TEMP_DIR" ] && rm -rf "$DIR"