From 2fabe40e9dd3e08e83b6df278e13596f55329019 Mon Sep 17 00:00:00 2001 From: tavo-wasd Date: Mon, 30 Oct 2023 10:06:55 -0600 Subject: [PATCH] share files over local network with python's http.server --- .gitignore | 2 +- scripts/share | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 scripts/share diff --git a/.gitignore b/.gitignore index e6a203e..25f055a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ lutris pcmanfm pulse surf/ -darktable +darktable/ galculator kalgebrarc kdenlive-layoutsrc diff --git a/scripts/share b/scripts/share new file mode 100755 index 0000000..89035ae --- /dev/null +++ b/scripts/share @@ -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"