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: 1155
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Sun Aug 27, 2017 6:45 am

Some time ago, picoweb was made to run on ESP8266 (or low-heap ports in general): viewtopic.php?f=16&t=2966#p20150
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/

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Question about using Keep-Alive

Post by bitninja » Wed Oct 11, 2017 5:24 am

Is there any way to inject the ETAG/Keep-Alive values into the response headers for specific responses?

I am trying to take advantage of the client caching of things like javascript and stylesheet files so that they are not reloaded every time a page is rendered. As it is, I can see them requested over and over again, which is really a waste.

Thanks.

Edit: OK, perhaps I meant using the Cache-Control : max-age construct in the HTTP header returned by the "server".

Image

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

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

Post by pfalcon » Sat Oct 28, 2017 4:13 pm

Sure, if you look at the picoweb examples, you'll see one which constructs a full HTTP reply, e.g. https://github.com/pfalcon/picoweb/blob ... app.py#L12 . So of course, you can add any headers you like.
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/

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

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

Post by bitninja » Thu Nov 16, 2017 4:25 am

Thanks for pointing that out. Not very helpful for what I need. But thanks.

I am using the sendfile() function and it already uses the standard header...

Code: Select all

# handle the root URL
def index(req, resp):
    yield from app.sendfile(resp, rootdir + "index.html")

# handle all other resource (file) requests
def file(req, resp):
    fname = req.url_match.group(1)
    yield from app.sendfile(resp, rootdir + fname)
as shown here https://github.com/pfalcon/picoweb/blob ... __.py#L245

Being new to Python, what is my best option for injecting these headers when I use sendfile() and just want to return a file?

Thanks.

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

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

Post by pfalcon » Sat Dec 16, 2017 10:40 am

1.3 was released: https://pypi.python.org/pypi/picoweb/1.3 . There's a backward incompatible change: https://github.com/pfalcon/picoweb/issues/21
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: 1155
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Sun Jan 14, 2018 11:01 am

1.3.1 was released: https://pypi.python.org/pypi/picoweb/1.3.1 .

It's now possible to add arbitrary headers to a reply: https://github.com/pfalcon/picoweb/blob ... t__.py#L39
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: 1155
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Sat Jan 27, 2018 11:10 am

micropython-lib, uasyncio, and picoweb keep evolving, and some not fully finished ports are starting to have issues due to missing functionality, e.g. https://github.com/pfalcon/picoweb/issues/31 . As mentioned in viewtopic.php?f=15&t=85&start=80#p24415, latest uasyncio, etc. require my fork of MicroPython https://github.com/pfalcon/micropython . More optimizations and new functionality are planned in the future beyond the mainline (which is as of now wasn't updated in a month).
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: 1155
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Tue Jan 30, 2018 9:19 am

An example of using extra headers in response was contributed: https://github.com/pfalcon/picoweb/blob ... headers.py . Shows serving gzip'ed content, cache control, etc.
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: 1155
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Sat Feb 24, 2018 8:54 pm

picoweb 1.4 was released: https://pypi.python.org/pypi/picoweb/1.4 . It allows to disable log output or configure it more flexibly using "logging" module. More info: https://github.com/pfalcon/picoweb/comm ... 59740aab01 , https://github.com/pfalcon/picoweb/comm ... 1f0a92a200
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: 1155
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Thu Nov 22, 2018 5:08 am

picoweb 1.5.1 was released: https://pypi.org/project/picoweb/1.5.1/ . It optimizes form handling a bit (and provides an form handling example, as that wasn't available previously), but makes small backward-incompatible change in that regard. The change and motivation are described in https://github.com/pfalcon/picoweb/comm ... 7e1a969112 (it's memory usage optimization, no surprise here).
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/

Post Reply