I do not know you have not encountered such a situation, is that you sometimes want to transport something on your computer to your phone or Pad, you either need to use the data cable connected to a computer, sometimes even install the various drivers data can be transmitted either need to use third-party tools on the LAN transmission, there is the use of micro-channel file transfer assistant ...
but these operations have some limitations, such as the driver is not installed on a variety of third-party tools suddenly sucker, or suddenly broken network, which the wtf.
However, there is nothing if not Python Well, today small to share with you a technique using a command can turn your computer into a server, so your phone can get your computer files directly. The command is: python3 -m http.server
When you finish execute this command, your computer listens on port 8000, as long as access to the port (mobile phones and computers required in the same local area network), your phone can get to you All of the files on the computer:
If you want to use a cell phone or other devices to access files on your computer, you can take a look at the IP address of this computer:
then use the phone "IP: port" can be visited:
access computer in the picture:
pick one:
you can also view PDF files directly to the computer:
of course, you can also directly access the computer's web page:
for large point files can also be downloaded directly down:
then you can at the local off-line phone slowly appreciate:
Python built-in library regressed, right?
Of course, you do not want to listen on port 8000 can be replaced by another, such as:
python3 -m http.server 8900 --bind 127.0.0.1
Python2 command like this:
python -m SimpleHTTPServer 8900
However, it can not only download upload, I handsome photos to a computer can not go, then how can the line? We already know that this is Python's built-in http.server
, so it can be inherited, function extension points out, that is, we want to also upload feature to add to. We know that to get files from your computer is operating GET
, up from the mobile terminal to upload files is POST
operating, so we can go and override these methods, just Xiaoshuai b in line to see someone inherits this module extends this functionality:
up and running:
can be accessed by phone to:
select a file:
the file uploads successfully:
computer terminal to receive the file:
the ok, more than that today small for you to share tips with which you can throw away the tools and various third-party drivers, their own love ye ye pass pass.