mirror of
https://github.com/mr0xb/scripts.git
synced 2026-08-28 03:44:57 -04:00
initial commit
This commit is contained in:
parent
2f723ac7ee
commit
62156a1d85
9 changed files with 68 additions and 0 deletions
22
util/pyhttp
Executable file
22
util/pyhttp
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
if command -v python3 &> /dev/null; then
|
||||
PYTHON_CMD="python3"
|
||||
elif command -v python &> /dev/null; then
|
||||
PYTHON_CMD="python"
|
||||
elif command -v python2 &> /dev/null; then
|
||||
PYTHON_CMD="python2"
|
||||
else
|
||||
echo "Error: No Python interpreter found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VERSION=$($PYTHON_CMD -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
|
||||
|
||||
if [[ "$VERSION" == 3.* ]]; then
|
||||
$PYTHON_CMD -m http.server --bind $1 --directory $2
|
||||
elif [[ "$VERSION" == 2.* ]]; then
|
||||
$PYTHON_CMD -m SimpleHTTPServer --bind $1 --directory $2
|
||||
else
|
||||
echo "Unknown Python version"
|
||||
fi
|
||||
Loading…
Reference in a new issue