jczic / MicroWebSrv

A micro HTTP Web server that supports WebSockets, html/python language templating and routing handlers, for MicroPython (used on Pycom modules & ESP32)
https://github.com/jczic/MicroWebSrv
MIT License
641 stars 116 forks source link

Post example on ESP32 not working #3

Closed rdagger closed 6 years ago

rdagger commented 6 years ago

The example _httpHandlerTestPost method fires but doesn't make it past the line formData = httpClient.ReadRequestPostedFormData(). There is no error message. Looks like the ReadRequestContent method is the culprit. The response stops in this method at b = self._socket.readall().

jczic commented 6 years ago

Thank you for your feedback. The readall() method waiting a closing connection. I updated by reading the ContentLength size now. Could you try on your ESP32 with the same browser and tell me the result please ?

rdagger commented 6 years ago

It's working now. Great Job!

2 small notes in microWebSrv.py:
_sys.excinfo() is not implemented (at least not on ESP32, not sure about ESP8266). uhashlib is not implemented either and it does not appear to be used in the code.

Also could you please post an example of how to serve existing files (html, png, pdf, etc.)

jczic commented 6 years ago

Thank you :) Yes, sys.exc_info () is on pycom modules (www.pycom.io) to show stack exceptions. Exactly for uhashlib: I forgot to remove it after integrate websockets handshake (future extension) ...

To directly serve existing files, this is already okay with main.py: copy the "www" directory in your flash and go to your ESP by http://ip-addr/ to get the index.html with image, favicon and attached pdf file download.