Ask Your Question
1

Even though the kerner.response function produces a Response object, the controller continues to run.

asked 2021-12-02 11:00:00 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-02-03 15:00:00 +0000

david gravatar image

This is because the Response object returned by the kerner.response function is not automatically sent to the client as a response. Instead, it is returned to the controller, which can then manipulate it further or use it in some way before sending it as a response.

In order to send the Response object as a response to the client, the controller needs to use the return statement to return the Response object. For example:

from flask import Flask, Response
app = Flask(__name__)

@app.route('/')
def hello_world():
    response = Response("Hello, World!")
    return response

if __name__ == '__main__':
    app.run()

In this example, the hello_world function returns the Response object created by the kerner.response function. This Response object is then sent to the client as the response to the HTTP request.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-12-02 11:00:00 +0000

Seen: 10 times

Last updated: Feb 03 '23