程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

One line of Python code to realize file sharing server - actual combat

編輯:Python

One line of code to achieve file sharing

In a LAN , Need to share the contents of a folder .

We can have... On any one python On the computer of the environment , Quickly set up a http Agreed services , Then share the contents of the files in the folder . Yes, just one line of code

It's that simple

Pass the relevant project documents of the computer through http The agreement is shared , Let other users in the LAN adopt IP The address can be accessed and downloaded directly .

1、 What needs to be shared

IP Address :192.168.0.111
Shared folders :file

2、python One click sharing

Shared code

PS D:\file> python -m http.server 9090 

3、 Sharing effects

4、 adopt http Direct access

Access the shared address directly in the browser + port , To access shared folders , It can also be downloaded .

 Browser open http://192.168.0.111:9090

Parameters,

--bind: The binding of IP and port , The default is native ip, The default port is 8080
PS D:\> python -m http.server -h
usage: server.py [-h] [--cgi] [--bind ADDRESS] [port]
positional arguments:
port Specify alternate port [default: 8000]
optional arguments:
-h, --help show this help message and exit
--cgi Run as CGI Server
--bind ADDRESS, -b ADDRESS
Specify alternate bind address [default: all
interfaces]
PS D:\>

In this paper, from https://juejin.cn/post/6973616671412092964, If there is any infringement , Please contact to delete .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved