简单的ftp服务器

import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer


def main():
    # 实例化用户授权管理
    authorizer = DummyAuthorizer()
    authorizer.add_user('user', '123456', '/', perm='elradfmwMT')
    authorizer.add_anonymous(os.getcwd())

    # 实例化FTPHandle
    handler = FTPHandler
    handler.authorizer = authorizer

    # 链接启动提示
    handler.banner = 'welcome to connect my ftp'

    server = FTPServer(('127.0.0.1', 2122), handler)
    server.max_cons = 256
    server.max_cons_per_ip = 5
    server.serve_forever()


if __name__ == '__main__':
    main()

 一行代码搞定

 

 

posted @ 2018-08-16 10:29 前方、有光 阅读(...) 评论(...) 编辑 收藏