import ftplib

ftphost = "localhost"
ftpport = 21 #default 
username = "hamada2"
password = "hamada2"

session = ftplib.FTP(timeout=30)
session.connect(ftphost, ftpport)
session.login(username, password)
#session.prot_p()
#change current working ditectory
#session.cwd("/test")

#get current working directory
#print(session.pwd())

#get a list of file and folder names
#names = session.nlst()
#print(names)

#upload file to FTP server
''' 
with open("message.txt", 'rb') as file:
    res = session.storbinary("STOR message.txt", file)

if res.startswith("226"):
    print("Ok")
else:
    print("No")
'''

#download file from FTP server
'''
with open("msg.txt", 'wb') as file:
    res = session.retrbinary("RETR msg.txt", file.write)

if res.startswith("226"):
    print("Ok")
else:
    print("No")
'''

#session.rename("msg.txt", "message.txt")

#session.delete("testText.txt")

session.cwd("/test")
session.mkd("newFolder2")

#session.rmd("newFolder")

#print(session.size("message.txt"))

#print(session.dir())


session.quit()
print("FTP session closed successfully")
