Good day.
I have a python web app flask. In my app, my goal is to upload a file from a remote machine to the pythonanywhere machine. The file then will be stored on a directory where I would like to put to an object in order to use for email sending automation in python.
I've used the following syntax:
htmlfile = glob.glob("/var/www/flask_app/static/files/*.html")
receiver = glob.glob("/var/www/flask_app/static/files/*.csv")
latest_file_html = max(htmlfile, key=os.path.getctime)
latest_file_rec = max(receiver, key=os.path.getctime)
Error:
ValueError: max() arg is an empty sequence
Investigation checking
-
I tested the functionality on a seperate file the glob.glob together with the syntax " max(path, key=os.path.getctime)" python anywhere environment and it works.
-
But going back with my actual whole code its not working.
Here's the actual error:
Traceback (most recent call last):
File "/home/mariondeguzman/.virtualenvs/first-flaskapp/lib/python3.9/site-packages/flask/app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "/home/mariondeguzman/.virtualenvs/first-flaskapp/lib/python3.9/site-packages/flask/app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/mariondeguzman/.virtualenvs/first-flaskapp/lib/python3.9/site-packages/flask/app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "/home/mariondeguzman/.virtualenvs/first-flaskapp/lib/python3.9/site-packages/flask/app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/var/www/flask_app/app.py", line 83, in automation_page