There was a convenient FTP server library called pyftpdlib in python, so I tried using it.
It seems that you can download it from pyftpdlib site ... It is recommended to use pip because it can be installed with one command.
pip install pyftpdlib
By the way, you can use PyCharm to execute pip using GUI! (Promotion)
The basics are as in Quick Start of Official Site.
I did it in a Windows environment, but I think it can be done with other OS
# -*- coding: utf8 -*-
import pyftpdlib.authorizers
import pyftpdlib.handlers
import pyftpdlib.servers
#Create an authenticated user
authorizer = pyftpdlib.authorizers.DummyAuthorizer()
authorizer.add_user('user', 'password', 'C:\\Users\\username\\Pictures', perm='elradfmw')
#Create a handler to manage individual connections
handler = pyftpdlib.handlers.FTPHandler
handler.authorizer = authorizer
#Launch an FTP server
server = pyftpdlib.servers.FTPServer(("127.0.0.1", 21), handler)
server.serve_forever()
In this example, an FTP server with C: \ Users \ username \ Pictures as the root directory will be launched.
Username: user, password: password You can log in with.
As a test, when I connected it with WinSCP, the contents of the image folder were displayed properly.
I haven't seen it yet, but it seems that there are various examples in Tutorial on the official website.