V
V
VN2021-12-24 10:42:12
linux
VN, 2021-12-24 10:42:12

Why doesn't the python3 web server function work?

Have a function

function web () {
echo "Enter a path to directory: "
read -e -p "Path to dir: " my_dir
read -p "Enter a port nambet   " web_port
echo $my_dir
echo $web_port
cd $mydir && python3 -m http.server $web_port
}

On startup I get
Serving HTTP on 0.0.0.0 port 9632 (http://0.0.0.0:9632/) ...
192.168.1.12 - - [24/Dec/2021 07:17:26] "GET / HTTP/1.1" 200 -
192.168.1.12 - - [24/Dec/2021 07:17:26] code 404, message File not found
192.168.1.12 - - [24/Dec/2021 07:17:26] "GET /favicon.ico HTTP/1.1" 404 -

If you just go to the desired directory and run
python3 -m http.server 9632
then everything works

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim, 2021-12-24
@Viji

try cd "$my_dir" - in quotes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question