LoginSignup
0
2

More than 3 years have passed since last update.

一時的に FTP サーバを仕立てる

Last updated at Posted at 2019-05-25

令和にもなってまだ FTP とか思うけど色々ありまして。

ftpd の設定面倒だなと思ってぐぐってたら pyftpdlib が良さそうで、実際良かった。

インストール

$ pip install pyftpdlib

実行

import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

# anonymous ユーザーはカレントディレクトリのファイルを、取得 (perm='r') できる
authorizer = DummyAuthorizer()
authorizer.add_anonymous(os.getcwd(), perm='r')

handler = FTPHandler
handler.authorizer = authorizer

server = FTPServer(('0.0.0.0', 21), handler)
server.serve_forever()
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2