码迷,mamicode.com
首页 > 编程语言 > 详细

python ---- ftp传输服务器[在本地建一个站点方便局域网访问]

时间:2018-10-31 23:28:59      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:client   传输服务   自己的   zed   rmi   ftp服务   return   服务   tps   

分享一个python 脚本 关于建立ftp服务器以供局域网内的同事访问

 ftp.py

 1 # -*- coding:utf-8 -*-
 2 import os
 3 from pyftpdlib.authorizers import DummyAuthorizer
 4 from pyftpdlib.handlers import FTPHandler
 5 from pyftpdlib.servers import FTPServer
 6  
 7  
 8 def main():
 9     # Instantiate a dummy authorizer for managing ‘virtual‘ users
10     authorizer = DummyAuthorizer()
11  
12     # Define a new user having full r/w permissions and a read-only
13     # anonymous user
14     authorizer.add_user(user, 12345, Z:\wwwroot\c++, perm=elradfmwM)
15     # authorizer.add_anonymous(os.getcwd())
16  
17     # Instantiate FTP handler class
18     handler = FTPHandler
19     handler.authorizer = authorizer
20  
21     # Define a customized banner (string returned when client connects)
22     handler.banner = "pyftpdlib based ftpd ready."
23  
24     # Specify a masquerade address and the range of ports to use for
25     # passive connections.  Decomment in case you‘re behind a NAT.
26     #handler.masquerade_address = ‘151.25.42.11‘
27     #handler.passive_ports = range(60000, 65535)
28  
29     # Instantiate FTP server class and listen on 0.0.0.0:2121
30     address = (0.0.0.0, 2121)
31     server = FTPServer(address, handler)
32  
33     # set a limit for connections
34     server.max_cons = 256
35     server.max_cons_per_ip = 5
36  
37     # start ftp server
38     server.serve_forever()
39  
40 if __name__ == __main__:
41     main()

先安装 pyftpdlib 之后根据自己的用户名和密码和对应的传输路径,修改这一行

authorizer.add_user(user, 12345, Z:\wwwroot\c++, perm=elradfmwM)

运行

python ftp.py

 

python ---- ftp传输服务器[在本地建一个站点方便局域网访问]

标签:client   传输服务   自己的   zed   rmi   ftp服务   return   服务   tps   

原文地址:https://www.cnblogs.com/Hwangzhiyoung/p/9886341.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!