Home >Backend Development >Python Tutorial >Using Python to implement local file sharing method on the same network

Using Python to implement local file sharing method on the same network

不言
不言Original
2018-06-04 11:20:202665browse

This article mainly introduces the method of using Python to realize local file sharing in the same network. It has certain reference value. Now I share it with you. Friends in need can refer to it.

This article uses Python3 Start a simple HTTP server to share local files within the same network.

Start the HTTP server

Open the terminal, go to the folder where the target file is located, and type the following command:

$ cd /Users/zero/Documents/localFiles
# python -m http.server <port number>
$ sudo python3 -m http.server 8092
Serving HTTP on 0.0.0.0 port 8092 (http://0.0.0.0:8092/) ...

Generate shared link

Open the browser and enter the URL: http://localhost:8092, which can be used locally View this document. Then type ifconfig in the terminal to check the local IP address, such as 192.168.199.154, and replace localhost with it to generate the link http://192.168.199.154:8092/.

Share local files

Share this link with anyone on the same network to share local files.

Related recommendations:

Detailed explanation of how to use Python to convert images into character paintings

How to use Python to implement shopping Program ideas and implementation code

##

The above is the detailed content of Using Python to implement local file sharing method on the same network. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn