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

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.
pfalcon
Posts: 1136
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Tue Jun 17, 2014 10:36 pm

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
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1136
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Tue Jun 17, 2014 10:38 pm

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/
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

randomhuman
Posts: 19
Joined: Mon Jun 09, 2014 1:54 pm

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

Post by randomhuman » Thu Jun 19, 2014 2:31 pm

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?

pfalcon
Posts: 1136
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Sat Jun 21, 2014 5:36 pm

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 ;-) ).
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1136
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Sun Oct 12, 2014 10:22 am

0.6.3 was released, updated to use recently added builtin "ujson" module.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1136
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Thu Nov 20, 2014 10:31 pm

0.7 released, improvements to static files handling.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1136
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Thu Jun 04, 2015 11:18 am

It seems that I didn't give a link to "notes-pico" example application I mentioned above: https://github.com/pfalcon/notes-pico
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

skylin008
Posts: 53
Joined: Wed Mar 11, 2015 6:21 am

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

Post by skylin008 » Thu Jan 28, 2016 9:13 am

@ pfalcon .Can Picoweb be run pyboard v10b successfully?

pfalcon
Posts: 1136
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Thu Jan 28, 2016 11:46 am

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.)
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

skylin008
Posts: 53
Joined: Wed Mar 11, 2015 6:21 am

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

Post by skylin008 » Fri Jan 29, 2016 3:12 am

Thanks for pfalcon. Pyboard v10b now been connected ESP8266-12F module via UART.Network connection is OK.

Post Reply