Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
'''FTP server for Pythonista (iOS)
You can use this to exchange files with a Mac/PC or a file management app on the same device (e.g. Transmit).
If you use a Mac, you can connect from the Finder, using the "Go -> Connect to Server..." menu item.
import os
from socket import gethostname
def install_pyftpdlib():
print 'Downloading pyftpdlib...'
import urllib
import shutil
urllib.urlretrieve('', 'pyftpd.tar.gz')
import tarfile
t ='pyftpd.tar.gz')
shutil.copytree('pyftpdlib-1.4.0/pyftpdlib', 'site-packages/pyftpdlib')
import pyftpdlib
except ImportError:
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
import threading
def main():
authorizer = DummyAuthorizer()
authorizer.add_anonymous(os.path.expanduser('~/Documents'), perm='elradfmwM')
handler = FTPHandler
handler.authorizer = authorizer
server = FTPServer(('', 2121), handler)
t = threading.Thread(target=server.serve_forever)
print 'Server started.'
print '\nConnect as guest/anonymous user to ftp://localhost:2121 (from this device) or "ftp://(YOUR_IP_ADDRESS):2121" (from other devices in your network -- you can find the IP address of your device in the WiFi settings)'
while True: pass
except KeyboardInterrupt:
print 'Server stopped'
if __name__ == '__main__':
Copy link

eebmagic commented May 12, 2018

whenever I try to run this on pythonista on my phone I just get a bunch of errors

Copy link

fullyninja commented Jun 16, 2019

This script is targeting Python 2.7. Try modifying the script for Python 3 or set the Pythonista to use 2.7 as the default interpreter.

Copy link

cclauss commented Feb 27, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment