MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
User avatar
Hyperion
Posts: 13
Joined: Wed Oct 16, 2019 9:34 am

Re: MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Post by Hyperion » Fri Nov 22, 2019 3:11 pm

dhylands wrote:
Wed Nov 20, 2019 3:36 pm
WHen I used it, I hd to make sure it was used as a frozen module.
Never done freezing before but always wanted to learn it. How do you freeze the whole folder though? Do I just have to put the whole folder into the modules directory before building?

Edit: Figured it out, server now started and I still have over 100kB of memory left 8-)

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Post by devnull » Wed Nov 27, 2019 10:23 am

Cant run this on SF6:

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "MicroWebSrv2/microWebSrv2.py", line 221, in StartManaged
  File "MicroWebSrv2/microWebSrv2.py", line 213, in StartManaged
  File "MicroWebSrv2/microWebSrv2.py", line 184, in StartInPool
MicroWebSrv2Exception: Not enough memory to allocate slots.

User avatar
Hyperion
Posts: 13
Joined: Wed Oct 16, 2019 9:34 am

Re: MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Post by Hyperion » Fri Dec 06, 2019 1:05 pm

How does sending response by a data stream work? I need to send a large file stored in another module back to a client, but I can read it through UART only by smaller chunks due to low available memory in the MPY board, so I think streaming it is my only option. I would like to send a packet after receiving 1024 bits through UART (stored in a bytearray), and only after the last packet is sent, I need to send the 200 OK response code.

The ReturnStream method needs to send a code so will it send only the first 1024-bit packet? How does it know to wait for another one? Btw I know the number of bits the file will have, before the UART transmission starts, if that helps.

rubenafonso
Posts: 2
Joined: Fri Dec 13, 2019 6:27 pm

Re: MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Post by rubenafonso » Fri Dec 13, 2019 6:37 pm

Hyperion wrote:
Fri Nov 22, 2019 3:11 pm
Edit: Figured it out, server now started and I still have over 100kB of memory left 8-)
Hi,

I have the same memory problem when try to run it on ESP32. @Hyperion, can you tell what you did to overcome this problem? Did you use the frozen?

Thanks in advance.

Regards,
Ruben

User avatar
Hyperion
Posts: 13
Joined: Wed Oct 16, 2019 9:34 am

Re: MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Post by Hyperion » Tue Dec 17, 2019 3:53 pm

rubenafonso wrote:
Fri Dec 13, 2019 6:37 pm
Hi,

I have the same memory problem when try to run it on ESP32. @Hyperion, can you tell what you did to overcome this problem? Did you use the frozen?

Thanks in advance.

Regards,
Ruben
Hi, yeah I froze the whole module. Just look for tutorials on how to freeze a module, there are a plenty (I can't find the one I used last time, sorry). Let me know if you need any help!

User avatar
Hyperion
Posts: 13
Joined: Wed Oct 16, 2019 9:34 am

Re: MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Post by Hyperion » Tue Dec 17, 2019 9:07 pm

Any convenient way to enable gzip compression for sending .gz files and non-zipped files only if the .gz files aren't found in the specified directory? I'm getting 404 on all requests for files that are present only as .gz

rubenafonso
Posts: 2
Joined: Fri Dec 13, 2019 6:27 pm

Re: MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Post by rubenafonso » Wed Dec 18, 2019 12:11 pm

Hyperion wrote:
Tue Dec 17, 2019 3:53 pm
Hi, yeah I froze the whole module. Just look for tutorials on how to freeze a module, there are a plenty (I can't find the one I used last time, sorry). Let me know if you need any help!
Hi,

Thanks for your help! I was able to run the server with the frozen the module!

I followed the example of these links: https://learn.adafruit.com/micropython- ... en-modules
The dependencies are the MicoPython source (https://github.com/micropython/micropyt ... orts/esp32) and the ESP32 toolchain (https://docs.espressif.com/projects/esp ... setup.html).

I hope this could help others in the future.

Best regards,
Ruben Afonso.

seonr
Posts: 43
Joined: Mon Sep 10, 2018 6:54 am

Re: MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Post by seonr » Mon Feb 17, 2020 9:22 pm

I just started using this in a project - thanks heaps for making it jczic!

I'm trying to use a pyhtml file as a default page, but it's giving me a [403: forbidden] whenever it tries to serve it.

I have the PyhtmlTemplate module loaded and I'm adding the file as a default page before I start the server, but I can't get it to work.

Other non .pythml files are working as expected.

Is this supported?

Thanks,
Seon
Unexpected Maker

seonr
Posts: 43
Joined: Mon Sep 10, 2018 6:54 am

Re: MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Post by seonr » Tue Feb 18, 2020 2:29 am

Ok, I just found this issue:
https://github.com/jczic/MicroWebSrv2/issues/22

It states .pyhtml files are not processed for default pages. That's a real shame. I get I can manage the '/' route and do a redirect to it, but that's another slow page change running on a microcontroller.

Is there a specific reason it's not loaded before so it can be used on default pages? Is it a memory or performance constraint?

Thanks,
Seon
Unexpected Maker

ChrisB
Posts: 7
Joined: Wed Mar 04, 2020 2:45 pm

Re: MicroWebSrv2, new asynchronous Web server for MicroPython (+Routes +WebSockets +Template engine).

Post by ChrisB » Wed Mar 04, 2020 3:00 pm

Hi,

I am new to µPython and ESP32.
I tried to use MicroWebSrv2 but I get this error :
File "main.py", line 145, in <module>
File "MicroWebSrv2/microWebSrv2.py", line 136, in LoadModule
MicroWebSrv2Exception: Cannot load module "PyhtmlTemplate".
I am using uPyCraft and I can see the file in the mods directory.
I have no idea why it's not able to load it?

Thanks for your help

Chris

Post Reply