Websocket example: 400 error and ENOENT in send_file #191
-
I am trying to get the websocket example working on my ESP32. But I get the following error when navigating to the default 'root' route:
When navigating to '/echo' I get nothing in the repl but 400 error in the browser. There seems to be some problem with the send_file method? My file tree looks something like this:
And the files are copies of: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The The quick and dirty solution would be to change the |
Beta Was this translation helpful? Give feedback.
The
ENOENT
error is short for "no such file or directory". It means that the path that you are passing tosend_file()
does not represent a file that can be opened. To me it sounds like your application is confusing templates with static files. Thesend_file()
function is used to send static files, but you have your index.html file in the templates directory.The quick and dirty solution would be to change the
send_file()
call tosend_file('templates/index.html')
. This function does not have any notion of where files are stored, you have to give it an absolute or relative path to the file. As a general recommendation I would suggest that if your html file is not going to be a template that…