from flask import Flask from flask.ext.bootstrap import Bootstrap from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) app.config.from_object('config.Configuration') Bootstrap(app) db = SQLAlchemy(app) class PrefixFix(object): def __init__(self, app, script_name): self.app = app self.script_name = script_name def __call__(self, environ, start_response): path = environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', '') environ['SCRIPT_NAME'] = self.script_name environ['PATH_INFO'] = path[len(self.script_name):] return self.app(environ, start_response) if not app.debug: app.wsgi_app = PrefixFix(app.wsgi_app, '/james')