miguelgrinberg / microdot

The impossibly small web framework for Python and MicroPython.
MIT License
1.5k stars 117 forks source link

Create a "mini" Microdot with reduced features #128

Closed miguelgrinberg closed 10 months ago

miguelgrinberg commented 1 year ago

While Microdot fits in most microcontroller architectures, in some such as the ESP8266 it is a tight fit often requiring frozen modules on custom built firmware. It would be nice to have a completely stripped-down version that can be used for a basic server.

Lestat-GitHub commented 1 year ago

Hi,

I'm also interested on a "microdot-minimal" version. I'm using it on ESP8266/8265 with 32K of RAM and the growth of memory usage is starting to be an issue for me.

I fully understand this growth (with all included features) but I would need a minimal version that just supports handling simple GET/PUT/POST commands.

Here are some values I measured about microdot's memory usage across different versions:

In my case it's half my available ram :(

BTW: Thanks for this project that is very useful for me :+1:

rkompass commented 1 year ago

Perhaps it matters in this context: I observed that the nice data structures NoCaseDict and MultiDict are both used just in one place, at least in microdot.py itself. I did an attempt to get rid of these but apparently missed something in recoding (website now renders without formatting). The memory consumption reduction by that was about 2K. @miguelgrinberg If you are interested I can post my changes.

Thank you for this nice project and thanks for this self-assignment. What I would appreciate most was a compact (1 file) asynchronous version of microdot. Something like tinyweb but in the better microdot style and working (tinyweb is not kept up to date). I'm interested in controlling robots over Wifi that have some activity of their own. So an async server is needed.

miguelgrinberg commented 1 year ago

@rkompass this is all coming in version 2. My current plan (may still change) is to have four "starter" scripts: the regular and async versions, plus two "mini" versions with only the most basic support. These are all going to be single file modules.

So an async server is needed.

Some boards offer limited multi-threading support. For example the Raspberry Pi Pico and Pico W have two cores, and can run two threads concurrently.

miguelgrinberg commented 10 months ago

Microdot 2 is now released. I ended up not implementing what I describe above, and instead opted for a simpler solution that reduces the size of the code by making everything work asynchronously (i.e. the sync support code has been removed). The documentation also includes information on cross-compiling to mpy and freezing the modules to save space.