Search found 34 matches

by cemox
Fri Nov 19, 2021 6:10 pm
Forum: General Discussion and Questions
Topic: Socket receives html code instead of plain text
Replies: 3
Views: 1607

Socket receives html code instead of plain text

Hi, you are all fine. I wrote a script which first starts in AP mode, asks the user to enter ssid and pasword for the wifi in web form then after restart it starts in station mode and connects to the wifi. Everything works fine, except one thing. When I enter special characters like "!, ', @", etc. ...
by cemox
Wed May 06, 2020 1:42 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 18
Views: 13123

Re: asyncio.start_server example (!)

Thank you Jomas, waiting for the blank lines solved both the server and the client side communication problems :) At last it worked ! Putting a small delay right after writer.awrite(resp) , solved the problem. The whole working code is : import uasyncio as asyncio import utime async def serve(reader...
by cemox
Wed May 06, 2020 12:22 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 18
Views: 13123

Re: asyncio.start_server example (!)

I will change the utime.sleep() to asyncio.sleep(). @pythoncoder and @jomas, thank you both for your comments. I can listen to the radio channels pretty well now. Now, I have another problem. I want to control my web radio from a remote web browser, my esp8266 board now works as a (AP) server and (S...
by cemox
Tue May 05, 2020 3:59 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 18
Views: 13123

Re: asyncio.start_server example (!)

At last it worked ! Putting a small delay right after writer.awrite(resp) , solved the problem. The whole working code is : import uasyncio as asyncio import utime async def serve(reader, writer): t = utime.ticks_ms() resp = b"HTTP/1.0 200 OK\r\n\r\n" + "Ticks = {TICKS}\r\n".format(TICKS=t) l = awai...
by cemox
Tue May 05, 2020 3:43 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 18
Views: 13123

Re: asyncio.start_server example (!)

Thank you for your comments Peter. Of course, I did not want to send the same sentence to the client 100 times. I noticed that it woks, if I do that. In your code, if I change the iteration to 5 for example, it doesn't work either: Browser says: "Safari Cannot Open the Page Because the Network Conne...
by cemox
Tue May 05, 2020 1:40 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 18
Views: 13123

Re: asyncio.start_server example (!)

Things getting more and more interesting. The code blow works, sending http header hundred times, when I change the multiplier to, say, 10, it doesn't work. Do you think it is a bug? import uasyncio as asyncio import utime async def serve(reader, writer): t = utime.ticks_ms() resp = b"HTTP/1.0 200 O...
by cemox
Tue May 05, 2020 9:07 am
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 18
Views: 13123

Re: asyncio.start_server example (!)

Thank you Peter, I will check PicoWeb. I am glad that I did not ask a stupid question :)
by cemox
Mon May 04, 2020 5:53 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 18
Views: 13123

Re: asyncio.start_server example (!)

I also noticed that the connections is somehow continues (or suspended), google chrome inspector says
CATION: request is not finished yet
Screenshot from 2020-05-04 19-14-54.png
Screenshot from 2020-05-04 19-14-54.png (83.79 KiB) Viewed 9003 times
by cemox
Sun May 03, 2020 8:31 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 18
Views: 13123

asyncio.start_server example (!)

I am trying to write a simple asyncio.start_server example, but it doesn't function properly. import uasyncio as asyncio async def handle_echo(reader, writer): # while (True): data = await reader.read(128) if (data): message = data.decode() addr = writer.get_extra_info('peername') print("Received %r...