Twisted is really convenient sometimes
Last update on .
Needed an FTP server. 25 lines of code later an FTP server that listens on a particular interface serving files from a given directory, and half of those 25 lines are about processing command-line arguments, getting network addresses and otherwise doing "not FTP" work.
Comments are closed.
Pingbacks are closed.
Mark Blakeney on 02/20/2014 4:36 a.m. #
Type this python one-liner in the directory from which you want the files served:
python3 -m http.server
Sorethroat on 02/20/2014 6:13 a.m. #
The http.server already included in Python makes Twisted an unnecessarily complex answer to an ftp solution.
It is arguably more useful to see Twisted applied to the yet unaddressed (or not well known-- in Python at least) problems of easily connecting two clients behind NAT's and firewalls with each other.
STUN servers, TURN servers, and ICE servers, or otherwise any other server that solves these now chronic NAT problems is what Python, and given its position as the Python network suite of choice, Twisted, needs now.
Mike Fletcher on 02/20/2014 9:35 a.m. #
Note: FTP server, *not* HTTP server. There are devices out there that can only pull from FTP. This was to allow one of those (embedded) ftp-only devices to be upgraded from the host device.
Oh, and the http server one-liner works in Python 2 as well:
python -m SimpleHTTPServer