Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6888927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:05:25+00:00 2026-05-27T06:05:25+00:00

Given a simple Flask application, I’m just curious about whether there is a proper

  • 0

Given a simple Flask application, I’m just curious about whether there is a proper way to modify a Response in the hooks such as process_response?

e.g. Given:

from flask import Flask, Response

class MyFlask(Flask):
    def process_response(self, response):
        # edit response data, eg. add "... MORE!", but
        # keep eg mimetype, status_code
        response.data += "... This is added" # but should I modify `data`?
        return response
        # or should I:
        #     return Response(response.data + "... this is also added",
        #                     mimetype=response.mimetype, etc)

app = MyFlask(__name__)

@app.route('/')
def root():
    return "abddef"

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

Is it proper to just create a new response each time, or is it canonical to just edit in-place the response parameter and return that modified response?

This may be purely stylistic, but I’m curious – and I haven’t noticed anything in my reading that would indicate the preferred way to do this (even though it’s probably quite common).

Thanks for reading.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:05:26+00:00Added an answer on May 27, 2026 at 6:05 am

    From the Flask.process_response docs:

    Can be overridden in order to modify the response object before it’s sent to the WSGI server.

    The response object is created on flask dispacher mechanism (Flask.full_dispatch_request). So if you want to create response objects under your own way, override Flask.make_reponse. Use Flask.process_response only when the desired modifications can be made using the created response object parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a simple statement, such as: <statement id=SelectProducts resultMap=???> SELECT * FROM Products </statement>
Given a simple (id, description) table t1, such as id description -- ----------- 1
Given a simple switch statement switch (int) { case 1 : { printf(1\n); break;
Given a simple namespaced route map.namespace :api do |api| api.resources :genres end how can
Given a simple C# class definition like: [System.Windows.Markup.ContentProperty(PropertyOne)] public class SimpleBase { public string
Given a simple data set, I would like to be able to calculate a
Given a simple class: public class Person { public string FirstName; public string LastName;
Given a simple parent/child class structure. I want to use linqkit to apply a
This is a purely theoretical question. Given three simple classes: class Base { }
Given a relatively simple CSS: div { width: 150px; } <div> 12333-2333-233-23339392-332332323 </div> How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.