https://github.com/larsks/micropython-noggin
It supports both "Expect: 100-continue" headers from clients and chunked encoding, which means it will interoperate nicely with e.g., "curl".
It uses a simple and hopefully not surprising interface for mapping request URIs to functions using regular expressions, and it maps match groups in your routes to positional parameters in your functions:
Code: Select all
from noggin import Noggin
app = Noggin()
@app.route('/')
def index(request):
return 'Here is some content for you'
@app.route('/doc/([^/]+)')
def get_doc(request, docid):
if docid in documents:
return documents[docid]
else:
raise HTTPError(404)
app.serve()
There is some simple demonstration code available at https://github.com/larsks/micropython-n ... es/demo.py that shows off most of the features. There is a slightly more involved demo available at https://github.com/larsks/micropython-n ... fileops.py that implements a simple http fileserver, with support for getting, putting, renaming, and deleting files. It also provides access to filesystem, memory, and network configuration information.
I'm running this on a Wemos D1 mini (clone), https://wiki.wemos.cc/products:d1:d1_mini, where it seems to be working fine so far.