One line ftp server in python

One line ftp server in python

Obligatory Twisted example:

twistd -n ftp

And probably useful:

twistd ftp --help

Usage: twistd [options] ftp [options].
WARNING: This FTP server is probably INSECURE do not use it.
  -p, --port=           set the port number [default: 2121]
  -r, --root=           define the root of the ftp-site. [default:
  --userAnonymous=  Name of the anonymous user. [default: anonymous]
  --password-file=  username:password-style credentials database
  --help            Display this help and exit.

Check out pyftpdlib from Giampaolo Rodola. It is one of the very best ftp servers out there for python. Its used in googles chromium (their browser) and bazaar (a version control system). It is the most complete implementation on Python for RFC-959 (aka: FTP server implementation spec).

To install:

pip3 install pyftpdlib

From the commandline:

python3 -m pyftpdlib


#!/usr/bin/env python3

from pyftpdlib import servers
from pyftpdlib.handlers import FTPHandler
address = (, 21)  # listen on every IP on my machine on port 21
server = servers.FTPServer(address, FTPHandler)

Theres more examples on the website if you want something more complicated.

To get a list of command line options:

python3 -m pyftpdlib --help

Note, if you want to override or use a standard ftp port, youll need admin privileges (e.g. sudo).

One line ftp server in python

Why dont you instead use a one-line HTTP server?

python -m SimpleHTTPServer 8000

will serve the contents of the current working directory over HTTP on port 8000.

If you use Python 3, you should instead write

python3 -m http.server 8000

See the SimpleHTTPServer module docs for 2.x and the http.server docs for 3.x.

By the way, in both cases the port parameter is optional.

Leave a Reply

Your email address will not be published. Required fields are marked *