Now quickly add file sharing functionality across a network with both http and ftp servers to your python project.
Quickly start a http or ftp over a directory to share data across a network.
Only works in a local area network
pip install easyFileShare
from easyFileShare import FS
obj = FS.FileShareClass()
obj.start_fileShare(self , folderToShare , port = 8000 , http = False , logToConsole = False , ftpDetails = ["userName" , "password_here"])
folderToShare is path to folder you want to share for example on windows you want to share a folder named hello in c drive then folderToShare = r"C:/hello"
By default the module will start a FTP server which is important if you want to download entire folders or upload files , you can easily access it via entiring the ftp server link provided in windows file explorer top bar
But FTP server may require specialsed software to access on mobile operation systems , so instead you can start a HTTP server their by making HTTP = True , but remember you cannot download entire folder or upload files using this
By default module does not output anything to console , if you want to get status of whats happing in server then set logToConsole = True
By default server will start at port 8000 but if you have some other service running at that port then you can change the port number as well , just make sure its btw 1000 and 10000
By default , FTP server will use user as username and 225588 as password for granting write permission to client , but you can change that by passing custom username and pass in ftpDetails list format
Module will return a list of strings containing info about how to connect to server on other device
Server is started as sub process so can easily be terminated , see termination method below
The subprocess generated during the server start will be killed
Note - port number is not added into this
if __name__ == "__main__":
Main is necessary as we create a child process during server start , and if we do not do this inside main , then process will be restarted again and produce error
if __name__ == "__main__": from easyFileShare import FS fil = FS.FileShareClass() print(fil.start_fileShare("C:/users/harsh/desktop" , http = False)) import time time.sleep(60) fil.stopFileShare()
['Visit ftp://192.168.1.6:8000 in file explorer or FTP browse to download files', 'For Uploading as well Visit ftp://user:firstname.lastname@example.org:8000 in same', 'Files only available to devices connected to the same network']