Certainly! You can use the pyftpdlib library to create a read-only FTP server in Python. Below are the steps to set up a Flask Python FTP server and receive files from another PC.
First, install the pyftpdlib library using pip:
pip install pyftpdlib
Next, you can create a Flask application with a route to start the FTP server and make it accessible over the local network. Here's an example of how to set up the server:
from flask import Flask, request
import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
app = Flask(__name__)
# Set up the FTP server
def start_ftp_server():
authorizer = DummyAuthorizer()
authorizer.add_anonymous(os.getcwd(), perm='elr')
handler = FTPHandler
handler.authorizer = authorizer
server = FTPServer(('0.0.0.0', 21), handler)
server.serve_forever()
# Route to start the FTP server
@app.route('/start_ftp_server', methods=['GET'])
def start_ftp():
start_ftp_server()
return 'FTP server started'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
After running the Flask application, the FTP server will be accessible on the local network. Now, to receive files from another PC, you can use an FTP client like FileZilla or command-line tools like ftp or curl. Here's an example using the ftp command-line tool:
ftp <server_ip>
Replace <server_ip> with the IP address of the machine running the Flask FTP server. You can then use the get command to download files from the server to your local machine.
Keep in mind that transferring files as large as 7GB-49GB over FTP might take a significant amount of time, depending on the network speed and the capabilities of the machines involved. Additionally, ensure that you have enough storage space on the receiving computer to accommodate the incoming files.