One line ftp server in python

前端 未结 9 1819
清歌不尽
清歌不尽 2020-12-07 08:03

Is it possible to have a one line command in python to do a simple ftp server? I\'d like to be able to do this as quick and temporary way to transfer files to a linux box wi

9条回答
  •  借酒劲吻你
    2020-12-07 08:18

    Install:

    pip install twisted
    

    Then the code:

    from twisted.protocols.ftp import FTPFactory, FTPRealm
    from twisted.cred.portal import Portal
    from twisted.cred.checkers import AllowAnonymousAccess, FilePasswordDB
    from twisted.internet import reactor
    
    reactor.listenTCP(21, FTPFactory(Portal(FTPRealm('./'), [AllowAnonymousAccess()])))
    reactor.run()
    

    Get deeper:

    http://twistedmatrix.com/documents/current/core/examples/

提交回复
热议问题