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 8009259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:23:35+00:00 2026-06-04T18:23:35+00:00

From what I understand, Apache mod_wsgi implements a python interpreter that runs alongside Apache

  • 0

From what I understand, Apache mod_wsgi implements a python interpreter that runs alongside Apache and serves CGI requests, but the difference between WSGI and CGI is that, with WSGI the Python session just keeps running as long as the Apache server is running whereas with CGI it has to restart every time the server gets a CGI request.

What I’d like to know is, is there a Python module that you can run separately from Apache, like in an interactive Python session, that will listen for CGI requests from Apache? So, for instance, you can have Apache running and your WSGI middleware not running, and then you can start an interactive Python session and import your WSGI middleware module and then it will serve CGI requests from Apache, and you can also shut it down without shutting down Apache. So it is a single session like Apache mod_wsgi, but it doesn’t have to always run concurrently with Apache, and you can run it from an interactive Python session.

Edit 1:

So for instance, I have this flask app, myapp.py:

from flask import Flask

app = Flask(__name__)
app.debug = True

app.apples = 0

@app.route('/')
def hello():
    app.apples += 1
    return 'blah: %d' % app.apples

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080)

And I can run it by typing python myapp.py, but it starts its own web server. Instead I’d like Apache to be the web server, but I’d like to be able to open an interactive python shell and type from myapp import * and have app listen for requests from Apache, and since I have my interactive shell, so I can do stuff like print app.apples or app.apples = 50 or whatever. I’m saying I want my web app to be separate from the web server, and to be interactive with the python shell.

And what I mean to say with app.apples is that it is a global variable, like a hit count for the number of times '/' has been accessed, and it persists as long as the app is running.

Edit 2:

Here’s another example.

myapp.py:

import web

def add_global_hook():
    g = web.storage({"counter": 0})
    def _wrapper(handler):
        web.ctx.globals = g
        return handler()
    return _wrapper

class Hello:
    def GET(self):
        web.ctx.globals.counter += 1
        return "<h1>Counter: %d</h1>" % web.ctx.globals.counter

urls = ("/", "Hello")
app = web.application(urls, globals())
app.add_processor(add_global_hook())
app.run()

Here, I can open a python interpreter and type from myapp import *, and it starts the web server, but while the web server is running, I’m blocked from using the interactive shell. Is there some way to run the server in a non-blocking way so that I can use the interactive shell?

  • 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-06-04T18:23:37+00:00Added an answer on June 4, 2026 at 6:23 pm

    Have your considered running gunicorn WSGI server with Apache as a front end proxy?

    If you are after ability to debug a live Python web application without needing to do anything too complicated, also look at:

    https://github.com/GrahamDumpleton/wsgi-shell

    You would just want to make sure you use mod_wsgi daemon mode within default of single daemon process if using mod_wsgi.

    BTW, your understanding of how mod_wsgi works is a bit wrong, but rather than try and correct that it would simply help that you explain better why you want to do what you are trying to do. Perhaps starting by presenting the actual problem rather than your perceived solution.

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

Sidebar

Related Questions

I found that Maven implies specific directory layout. But I don't understand from here:
From what I understand PRNG uses a seed that generates a sequence of numbers
I understand how to ban an IPs address from my apache webserver using .htaccess:
I understand that this is a very long question, but i wanted to ask
My website is written in Python and currently runs under mod_python with Apache. Lately
i want to understand from the below code y the value of static variable
From what I understand, using Wiki and this question I posted, Microsoft has its
From what I understand, it should automatically have it installed. What I have installed
From what I understand, if scope=prototype is given for a bean, a new instance
From what I understand of REST principles, URLs should represent a single resource, like

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.