Skip to content

Executing code after request has ben responded to #289

@mirko

Description

@mirko

Is your feature request related to a problem? Please describe.

This is slightly related to #105

In a request handler I drop the layer2 connection (wifi on esp32).
That leaves the webbrowser hanging, eventually timing out.

Describe the solution you'd like

In my little world, a decorator alike after_request would solve the issue, but after sending out the response - let's name it afterafter_request.

So, a request handler could respond and complete the HTTP request (e.g. by sending 200/OK), and then disconnect from wifi.

Describe alternatives you've considered
Initially I figured the after_request-decorator would maybe do what I want. But its decorated function is being called before the HTTP client is being responded to.

Also, e.g.:

    try:
        print("OOO", "Responding to client")
        return "OK!"
    finally:
        print("OOO", "Disconnecting from wifi")
        wifi.disconnect()

does not appear to send the response before disconnecting from wifi, despite the print() statements being executed in the correct order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions