Dear all.
Last week I made my first steps with MicroPython and my ESP8266 12E.
I used ESPlorer on Windows 10 to upload code to the ESP8266.
All worked fine but when I tried to load the code of a simple webserver program as a module I got an error.
This is part of the code
......
def handleRequests(s):
cl, addr = s.accept()
print('client connected from', addr)
cl_file = cl.makefile('rwb', 0)
while True:
line = cl_file.readline()
if not line or line == b'\r\n': ### <<<--- THIS IS LINE 69 !!!
break
response = createHTML(getTemp())
cl.send(response)
cl.close()
......
The error was:
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "myModule.py", line 69
SyntaxError: invalid syntax
I had to mask the "\" bei "\\" to make the import of this code as a module work.
Is this a bug or did I make a mistake?
Thanks a lot in advance.
Best regards, Uwe
Problem loading module containing \r\n
Re: Problem loading module containing \r\n
There is no problem with \r or \n in MicroPython string handling. I guess that ESPlorer is the culprit, doing an additional escaping of \. Try another tool like rshell or ampy or Webrepl for uploading.
Re: Problem loading module containing \r\n
Dear Robert,
thanks for your fast reply.
And indeed - it was a problem which I had only with ESPlorer.
Actually I'm using uPyLoader from this github project https://github.com/BetaRavener/uPyLoader
And with this tool I have no problems any more.
Bye, Uwe
thanks for your fast reply.
And indeed - it was a problem which I had only with ESPlorer.
Actually I'm using uPyLoader from this github project https://github.com/BetaRavener/uPyLoader
And with this tool I have no problems any more.
Bye, Uwe