添加用户
from pyftpdlib.authorizers import DummyAuthorizer
authorizer = DummyAuthorizer()
authorizer.add_user('user', 'password', '/home/user', perm='elradfmw')
authorizer.add_anonymous('/home/nobody')
建立处理客户端命令的实例
from pyftpdlib.handlers import FTPHandler
handler = FTPHandler
handler.authorizer = authorizer
运行服务器
from pyftpdlib.servers import FTPServer
address = ('127.0.0.1', 21)
server = FTPServer(address, handler)
server.serve_forever()
-
其实安装好ftpdlib模块后,命令行里一句话启动ftp服务器
python -m pyftpdlib
要是想改变一下目录,设置一下IP地址和端口号
python -m pyftpdlib -i localhost -p 8021 -d /home/someone
或者还想改动一下其他
python -m pyftpdlib -h 用这个去看详细的帮助选项吧!