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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:48:49+00:00 2026-06-14T22:48:49+00:00

I am trying to setup middlewares on my server for python so that subdirectories

  • 0

I am trying to setup middlewares on my server for python so that subdirectories of blueprints can be seen by the apache2 on the server and served under a url like example.com/myapplicationsubfolder/routedblueprintfunction

my __init__.py inside /users/ folder looks like this:

class WebFactionMiddleware(object):
    def __init__(self, app):
        self.app = app
    def __call__(self, environ, start_response):
        environ['SCRIPT_NAME'] = '/myapplicationsubfolder'
        return self.app(environ, start_response)


from index import application
application.wsgi_app = WebFactionMiddleware(application.wsgi_app)

After I made my app factory, I couldn’t use this anymore:

from app import app
app.wsgi_app = WebFactionMiddleware(app.wsgi_app)

And I am trying to get the flask app from index.py

Index.py is like this:

from app import create_app
application = create_app()
application.run()

app.py like this:

def configure_errors(app):
  @app.errorhandler(500)
  def internal_server_error(error):
      return render_template('500.html'), 500

def create_app():
    app = Flask(__name__)
    app.config.from_object('config')

    from users.views import b_users
    db.init_app(app)
    app.register_blueprint(b_users)
    configure_errors(app)

    return app

If anyone has a link to a large blueprinted-appfactory-implemented source code that uses WSGI middlewares for subdirectories for a python Flask website, it would be of great help.

I’m having some serious circular import problems or subdirectory init.py issues.

[Sat Nov 24 05:32:59 2012] [error] [client 127.0.0.1] Traceback (most recent call last):
[Sat Nov 24 05:32:59 2012] [error] [client 127.0.0.1]   File "/home/somefolder/webapps/applicationsubfolder/htdocs/index.py", line 8, in <module>
[Sat Nov 24 05:32:59 2012] [error] [client 127.0.0.1]     from app import create_app
[Sat Nov 24 05:32:59 2012] [error] [client 127.0.0.1]   File "/home/somefolder/webapps/applicationsubfolder/htdocs/app.py", line 5, in <module>
[Sat Nov 24 05:32:59 2012] [error] [client 127.0.0.1]     from users.views import b_users
[Sat Nov 24 05:32:59 2012] [error] [client 127.0.0.1]   File "/home/somefolder/webapps/applicationsubfolder/htdocs/users/__init__.py", line 9, in <module>
[Sat Nov 24 05:32:59 2012] [error] [client 127.0.0.1]     from index import application
[Sat Nov 24 05:32:59 2012] [error] [client 127.0.0.1]   File "/home/somefolder/webapps/applicationsubfolder/htdocs/index.py", line 8, in <module>
[Sat Nov 24 05:32:59 2012] [error] [client 127.0.0.1]     from app import create_app
[Sat Nov 24 05:32:59 2012] [error] [client 127.0.0.1] ImportError: cannot import name create_app
  • 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-14T22:48:50+00:00Added an answer on June 14, 2026 at 10:48 pm

    I am not entirely sure of your requirement. Let me try though.

    1. If you want to prefix blueprint folder name before the view function url, do this:

      app.register_blueprint(b_users, url_prefix=’/folder_name’)

      Url will be localhost/folder_name/url

    2. Move this inside create_app method.

      app.wsgi_app = WebFactionMiddleware(app.wsgi_app)
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying setup a Rails app that will be something like a game. The
Im trying to setup my asp.net mvc page like the following image: The header
I'm trying to setup the application server part of C2DM push messaging using this
I'm trying to setup a binary socket connection in Flash to a server other
I am trying setup TeamCity webserver on a server run Apache Proxy. I added
I'm trying setup a map that displays different pin colors depending on the type/class
Trying to setup a server on Rackspace.com. Have done the following things: Installed Centos
So I am trying to setup an entry posting system, where the user can
Trying to setup a SQL stored procedure that if the variable passed to it
Here's the setup: Django (1.2) app on mod_wsgi that imports ctypes Python 2.6.5 Apache

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.