Download svn checkout http://pysendfile.googlecode.com/svn/pysendfile-read-onlycd pysendfile-read-only/ python First setup.py buildpython setup.py Install svn checkout http://pyftpdlib.googlecode.com/svn/trunk/pyftpdlib-read-only CD Pyftpdlib-read-only/python setup.py buildpython setup.py Install
Vim ftpserver.py
#!/usr/bin/env pythonfrom pyftpdlib Import ftpserverauthorizer = Ftpserver. Dummyauthorizer () authorizer.add_user ("User", "12345", "/home/great", perm= "ELRADFMW") authorizer.add_anonymous ("/ Home/great ") handler = Ftpserver. Ftphandlerhandler.authorizer = Authorizeraddress = ("127.0.0.1", +) ftpd = Ftpserver. Ftpserver (address, handler) Ftpd.serve_forever ()
Python ftpserver.py
Someone else's code
From pyftpdlib.authorizers import dummyauthorizerfrom pyftpdlib.handlers import Ftphandlerfrom pyftpdlib.servers Import Ftpserverdef Main (): # Instantiate a dummy authorizer for managing ' virtual ' users authorizer = Dummyauthoriz ER () # Define A new user has full r/w permissions and a read-only # anonymous user authorizer.add_user (' user ', ' 12345 ', '. ', perm= ' ELRADFMWM ') authorizer.add_anonymous (OS.GETCWD ()) # instantiate FTP Handler Class handler = Ftphandler Handler.authorizer = authorizer # Define a customized banner (string returned when client connects) Ha Ndler.banner = "Pyftpdlib based ftpd ready." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you ' re behind a NAT. #handler. masquerade_address = ' 151.25.42.11 ' #handler. Passive_ports = Range (60000, 65535) # instantiate FTP Server C Lass and listen on 0.0.0.0:2121 address = (", 2121) Server = Ftpserver (address, handler) # set a limit for connections server.max_cons = SERVER.MAX_CONS_PER_IP = 5 # start FTP server Server.s Erve_forever () if __name__ = = ' __main__ ': Main ()
Document
Http://pythonhosted.org/pyftpdlib/index.html
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Python quickly builds FTP with Pyftplib