I have prepared a python code for users to download their logs and save them in their download directory, they do some activity, and based on that activity log will be generated. With below code, log files go to server’s Download folder not user’s download folder. I don’t know how to modify my os.path.join. please consider not a specific user will use this portal and different users are going to use this portal.
I really appreciate if you can help me!
path_to_download_folder = str(os.path.join(Path.home(), "Downloads")) today = str(datetime.date.today()).split('-') NowTime = str(datetime.datetime.now())[11:19:] Nowtime_split = NowTime.split(':') timestamp=Nowtime_split+Nowtime_split+Nowtime_split daystamp=today+today+today filename = os.path.join(path_to_download_folder, 'log' +daystamp + '_' + timestamp + '.csv') with open(filename,"w+") as f: print(written_log) print(written_log, file=f) except AttributeError: file = open(logfile_name, 'a') timestamp = str(datetime.datetime.now())[:19] written_log = timestamp + ',' + req_text file.writelines(written_log + '\n')