libesphttpd bindings for MicroPython

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.
Post Reply
User avatar
jkent
Posts: 1
Joined: Fri Mar 26, 2021 9:30 pm

libesphttpd bindings for MicroPython

Post by jkent » Fri Mar 26, 2021 9:48 pm

Hi, I've been working on MicroPython C bindings for libesphttpd, which is in the middle of a rewrite. Part of the design involves route callbacks, and I'm currently dealing with a panic when running native python code when accessing a C object. Basically, I can use print() in my callback, but if I use any methods on my "conn" object it crashes. Any help would be greatly appreciated. (OT: I'm still considering some design choices for libesphttpd, such as per-connection tasks. The current design uses a single task for all connections using select() with per-connection write buffers. This was a design decision made when Sprite_tm originally designed it for the esp8266.)

Code: Select all

import http
server = http.server()

def hello_handler(conn):
    print('here!') # works
    print(conn) # works
    dir(conn) # crash!

    #conn.start_response(200)
    #conn.header('Content-Type', 'text/plain')
    #conn.end_headers()
    #conn.enqueue('Hello micropython world!')
    return http.STATUS_DONE

server.routes.insert_tail('*', hello_handler)
Here is the backtrace:
https://pastebin.com/48wt8JxS

Module source:
https://gist.github.com/jkent/c937e9e37 ... 433379779b

libesphttpd (rewrite branch):
https://github.com/jkent/libesphttpd/tree/rewrite

Post Reply