Sometimes we have such a need , Local files or remote files need to be sent through the remote terminal FTP After downloading the tool , Then pass it on to others through some social software , This is a little time-consuming and laborious , If I tell you to use Python can 1 Seconds to start one http File download server , And then ip and port Tell others , Let others download it manually according to their own needs , Is this more convenient ?
So how to quickly start a file download server ?
In fact, you only need to execute the following commands in a local directory :
python -m SimpleHttpServer
python3 -m http.server
Local directory structure :
$ ls go
$ bin pkg src
The starting effect is as follows :
$ python3 -m http.server
Serving HTTP on :: port 8000 (http://[::]:8000/) ...
::1 - - [22/Feb/2022 08:52:43] "GET / HTTP/1.1" 200 -
At this point, the browser accesses the corresponding http://ip:port
( The default is :http://0.0.0.0:8080), You can download the required files directly on the browser
Tips:
index.html
file , The file will be displayed on the browser by default , If there is no such file , Only the structure of the directory will be displayed