PicoWeb As Simple Content Server

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

PicoWeb As Simple Content Server

Post by bitninja » Fri Aug 11, 2017 1:49 am

I've managed to build a custom firmware that has picoweb embedded as frozen modules. Then I added a simple server script that simply delivers content from a folder on the flash file system...

Code: Select all

import ure as re
import picoweb

ROUTES = [
    ("/", lambda req, resp: (yield from app.sendfile(resp, "/wwwroot/index.html"))),
    (re.compile("^/(.+)"), lambda req, resp: (yield from app.sendfile(resp, "/wwwroot/" + req.url_match.group(1)))),
]

import logging
logging.basicConfig(level=logging.INFO)

app = picoweb.WebApp(None, ROUTES)
app.run(debug=True,host="0.0.0.0")
It works well for me... most of the time. Once the page being rendered contains a fair amount of graphics though, the ESP8266 falls behind and images are lost.

Anyway, it is quite exciting that we have tools like this to work with!

Post Reply