Page 1 of 3

picoweb - Web micro (well, pico) framework (with webserver, etc.)

Posted: Tue Jun 17, 2014 10:36 pm
by pfalcon
There's whole bunch of Python web microframeworks. They typically size at least a hundred of kilobytes and have bunch of dependencies (many claim they don't have dependencies, which means they depend on bloated CPython stdlib). 100K of Python alone not loadable to standard MicroPython heap (less than 128K), and http.client module from CPython stdlib requires ~600K to make a request.

So, after looking into all this, it became clear that none of existing web frameworks would be suitable for MicroPython, so I proceeded to write dedicated one. Someone already tried to write "nano framework", so I decided to target for "pico".

Picoweb (https://github.com/pfalcon/picoweb) is based on:
Picoweb is also available via PyPI: https://pypi.python.org/pypi/picoweb

Re: picoweb - Web micro (well, pico) framework

Posted: Tue Jun 17, 2014 10:38 pm
by pfalcon
The whole implementation is in proof of concept stage. Just today I finally was able to finish port of Charles Laifer's "Notes" webapp: http://charlesleifer.com/blog/saturday- ... ith-flask/

Re: picoweb - Web micro (well, pico) framework

Posted: Thu Jun 19, 2014 2:31 pm
by randomhuman
Will this be usable to serve an API or web interface for an application running on a microcontroller board, or is it more intended for the unix port?

Re: picoweb - Web micro (well, pico) framework

Posted: Sat Jun 21, 2014 5:36 pm
by pfalcon
Well, in the intro I described, that I looked at the bunch of microframeworks, but dismissed them, because there was no way they would run with the heap size available on PyBoard. Instead, I decided to write one from scratch, to keep it unbloated, and to ultimately be able to run it on MCU-level environment. That said, my primary development and usage platform is Unix port of MicroPython. So, whoever interested to run it on MCU board, would need to contribute to the project. And of course, that requires some kind of TCP/IP connectivity - ideally, BSD sockets API (including non-blocking mode), though any other sensible API should be easy to integrate either.

Currently, a trivial webapp can be run in 64K of heap. I have to say, that's much more than I expected (compare that with similar confession in http://forum.micropython.org/viewtopic. ... t=154#p651 ;-) ). For comparison, simple single-threaded server from examples/unix/ can run in 10K (which is, as you may expect, is more than I expected either ;-) ).

Re: picoweb - Web micro (well, pico) framework

Posted: Sun Oct 12, 2014 10:22 am
by pfalcon
0.6.3 was released, updated to use recently added builtin "ujson" module.

Re: picoweb - Web micro (well, pico) framework

Posted: Thu Nov 20, 2014 10:31 pm
by pfalcon
0.7 released, improvements to static files handling.

Re: picoweb - Web micro (well, pico) framework

Posted: Thu Jun 04, 2015 11:18 am
by pfalcon
It seems that I didn't give a link to "notes-pico" example application I mentioned above: https://github.com/pfalcon/notes-pico

Re: picoweb - Web micro (well, pico) framework

Posted: Thu Jan 28, 2016 9:13 am
by skylin008
@ pfalcon .Can Picoweb be run pyboard v10b successfully?

Re: picoweb - Web micro (well, pico) framework

Posted: Thu Jan 28, 2016 11:46 am
by pfalcon
I didn't have a chance to test that, sorry, as the main target for picoweb was Unix port. Based on initial memory usage profiling, it should be able to run there, at least with the simplest webapps. And recently, work on optimizing uasyncio started and already gives some fruits, so ability to run on embedded boards should improve. But I can't handle it all myself, so it waits for interested parties to join the efforts. (Mind that pyboard by default doesn't have network connection, so that needs to be resolved first.)

Re: picoweb - Web micro (well, pico) framework

Posted: Fri Jan 29, 2016 3:12 am
by skylin008
Thanks for pfalcon. Pyboard v10b now been connected ESP8266-12F module via UART.Network connection is OK.