I want to built a simple FTP server in python which will serve the client in just downloading a text file. Can any one kindly help me by suggesting the best study material to refer and help me finding some code snippets.
            Asked
            
        
        
            Active
            
        
            Viewed 2.9k times
        
    6
            
            
        - 
                    Must it be FTP? HTTP would be much simpler. – Ignacio Vazquez-Abrams Oct 23 '10 at 18:41
 
3 Answers
4
            
            
        I can recommend pyftpdlib hosted at Github
Example:
>>> from pyftpdlib.authorizers import DummyAuthorizer
>>> from pyftpdlib.handlers import FTPHandler
>>> from pyftpdlib.servers import FTPServer
>>>
>>> authorizer = DummyAuthorizer()
>>> authorizer.add_user("user", "12345", "/home/giampaolo", perm="elradfmw")
>>> authorizer.add_anonymous("/home/nobody")
>>>
>>> handler = FTPHandler
>>> handler.authorizer = authorizer
>>>
>>> server = FTPServer(("127.0.0.1", 21), handler)
>>> server.serve_forever()
[I 13-02-19 10:55:42] >>> starting FTP server on 127.0.0.1:21 <<<
[I 13-02-19 10:55:42] poller: <class 'pyftpdlib.ioloop.Epoll'>
[I 13-02-19 10:55:42] masquerade (NAT) address: None
[I 13-02-19 10:55:42] passive ports: None
[I 13-02-19 10:55:42] use sendfile(2): True
[I 13-02-19 10:55:45] 127.0.0.1:34178-[] FTP session opened (connect)
[I 13-02-19 10:55:48] 127.0.0.1:34178-[user] USER 'user' logged in.
[I 13-02-19 10:56:27] 127.0.0.1:34179-[user] RETR /home/giampaolo/.vimrc completed=1 bytes=1700 seconds=0.001
[I 13-02-19 10:56:39] 127.0.0.1:34179-[user] FTP session closed (disconnect).
2
            Check out the FTP examples with twisted
Also a simple implementation: ftpdrop.py
        pyfunc
        
- 65,343
 - 15
 - 148
 - 136
 
- 
                    Thanks again...The whole day i was doing google for FTP sample code,but i wasn't successful.... U made my work simpler...Thanks a lot... – Nilesh Nar Oct 23 '10 at 20:03
 
0
            
            
        This is probably the best you can find to understand the FTP protocol. Implementation should be pretty simple once you've understood the mechanism.
        Francesco De Vittori
        
- 9,100
 - 6
 - 33
 - 43
 
- 
                    I have gone through the details of ftp protocol, but the implementation using it is bit different. I want a simple sample code to get some idea of it. – Nilesh Nar Oct 23 '10 at 18:48
 -