Commit 8708a29
xxwhirlpool
·
2026-04-12 22:16:44 -0400 EDT
parent ca7ef8a
imgtools, update serveit to support cgi server
2 files changed,
+26,
-3
+18,
-0
| ... | ... | @@ -0,0 +1,18 @@ | |
| 1 | + | #!/usr/bin/env bash | |
| 2 | + | ||
| 3 | + | cropcenter() { | |
| 4 | + | imgfile=$(gum file ./) | |
| 5 | + | ext="${imgfile##*.}" | |
| 6 | + | newname="${imgfile%.*}_new".$ext | |
| 7 | + | magick "$imgfile" -gravity center -crop 1:1 +repage "$newname" | |
| 8 | + | } | |
| 9 | + | ||
| 10 | + | choice() { | |
| 11 | + | choose=$(gum choose "cropcenter") | |
| 12 | + | case "$choose" in | |
| 13 | + | cropcenter) cropcenter ;; | |
| 14 | + | *) exit;; | |
| 15 | + | esac | |
| 16 | + | } | |
| 17 | + | ||
| 18 | + | choice |
+8,
-3
| ... | ... | @@ -4,8 +4,8 @@ | |
| 4 | 4 | # https://codeberg.org/EvanHahn/dotfiles/src/commit/f7a9d94ae2254cb7e5f67e6e5bdb74b6467f6dec/home/bin/bin/serveit | |
| 5 | 5 | ||
| 6 | 6 | usage_help() { | |
| 7 | - | echo "Usage: serveit [-p] [-r | -y]" | |
| 8 | - | echo "Options: -p (port, optional) | -r (ruby) | -y (python)" | |
| 7 | + | echo "Usage: serveit [-p] [-r | -y | -c]" | |
| 8 | + | echo "Options: -p (port, optional) | -r (ruby) | -y (python) | -c (python CGI)" | |
| 9 | 9 | } | |
| 10 | 10 | ||
| 11 | 11 | if [[ $# -eq 0 ]]; then |
| ... | ... | @@ -18,14 +18,19 @@ py_server() { | |
| 18 | 18 | [[ "$(command -v python3)" ]]; python3 -m http.server "${port:-$port_default}" || echo "could not run python server" | |
| 19 | 19 | } | |
| 20 | 20 | ||
| 21 | + | pycgi_server() { | |
| 22 | + | [[ "$(command -v python3)" ]]; python3 -m http.server --bind localhost --cgi "${port:-$port_default}" || echo "could not run python CGI server" | |
| 23 | + | } | |
| 24 | + | ||
| 21 | 25 | rb_server() { | |
| 22 | 26 | [[ "$(command -v ruby)" ]]; ruby -run -e httpd . -p "${port:-$port_default}" || echo "could not run ruby server" | |
| 23 | 27 | } | |
| 24 | 28 | ||
| 25 | - | while getopts "p:ryh" opt; do | |
| 29 | + | while getopts "p:rych" opt; do | |
| 26 | 30 | case "$opt" in | |
| 27 | 31 | p) port="$OPTARG" ;; | |
| 28 | 32 | y) py_server ;; | |
| 33 | + | c) pycgi_server ;; | |
| 29 | 34 | r) rb_server ;; | |
| 30 | 35 | h) usage_help ;; | |
| 31 | 36 | *) echo "something went wrong" ;; |