Example #1
0
def make_app(subdomain):
    user = get_user_for_subdomain(subdomain)
    if user is None:
        # if there is no user for that subdomain we still have
        # to return a WSGI application that handles that request.
        # We can then just return the NotFound() exception as
        # application which will render a default 404 page.
        # You might also redirect the user to the main page then
        return NotFound()

    # otherwise create the application for the specific user
    return create_app(user)
Example #2
0
# --------------------------
# Parse command line options
# --------------------------
parser = argparse.ArgumentParser(description="Script to start the application server.")
parser.add_argument("-d", "--debug", help="Launch app in debug mode.", action="store_true", required=False)
parser.add_argument("-p", "--port", help="Port to use in debug mode.", default=5000, type=int, required=False)
parser.add_argument("-r", "--rules", help="List registered rules.", action="store_true", default=False, required=False)

args = parser.parse_args()

# -------------------
# Create app instance
# -------------------
from myapplication import create_app

app = create_app(debug=args.debug, conf=conf)  # actually creates the Flask application instance

# -----------------------------------------
# If using SQLAlchemy, uncomment this block
# -----------------------------------------
if conf["usingSQLAlchemy"]:

    # Can't create the database connection unless we've created the app
    from myapplication.model.database import db

    @app.teardown_appcontext
    def shutdown_session(exception=None):
        """ Enable Flask to automatically remove database sessions at the
	   	end of the request or when the application shuts down.
	   	Ref: http://flask.pocoo.org/docs/patterns/sqlalchemy/
	   """
Example #3
0
                    required=False)
parser.add_argument('-r',
                    '--rules',
                    help='List registered rules.',
                    action="store_true",
                    default=False,
                    required=False)

args = parser.parse_args()

# -------------------
# Create app instance
# -------------------
from myapplication import create_app

app = create_app(debug=args.debug,
                 conf=conf)  # actually creates the Flask application instance

# -----------------------------------------
# If using SQLAlchemy, uncomment this block
# -----------------------------------------
if conf["usingSQLAlchemy"]:

    # Can't create the database connection unless we've created the app
    from myapplication.model.database import db

    @app.teardown_appcontext
    def shutdown_session(exception=None):
        ''' Enable Flask to automatically remove database sessions at the
	   	end of the request or when the application shuts down.
	   	Ref: http://flask.pocoo.org/docs/patterns/sqlalchemy/
	   '''
Example #4
0
def make_app(prefix):
    user = get_user_for_prefix(prefix)
    if user is not None:
        return create_app(user)
def make_app(prefix):
    user = get_user_for_prefix(prefix)
    if user is not None:
        return create_app(user)