from ftplib import parse150 import os, sys def txthandler(path, htmlfile): filename = path[path.rfind('/')+1: path.rfind('.')] f = open(path, "r") contents = f.read() htmlfile.write('' '' '' '' +filename+ '' '' '' '' '' '' '

' +contents[0:contents.find('\n')]+ '

' '
' '

  Introduction  

' '

'+contents[contents.find('\n'):contents[contents.find('\n'):].find('.\n')+contents.find('\n')+1]+'

' '
' '' '') print(f.read()) return 0 def pdfhandler(path): f = open(path) print(f.read()) return 0 def dochandler(path): f = open(path) print(f.read()) return 0 #Attempting to pass txt file in path path = 'C:/Users/a big fuck/Documents/beansandtoast.txt' extension = path[path.rfind('.')+1: len(path)] filename = path[path.rfind('/')+1: path.rfind('.')] if os.path.exists(filename+".html") == True: os.remove(filename+".html") htmlfile = open(filename+".html", "x") if extension =='txt': txthandler(path, htmlfile) elif extension == 'pdf': pdfhandler(path) elif extension == 'doc' or 'docx': dochandler(path) else: print("Extension not recognized") sys.exit()