2015-03-26 21:49:14 +01:00
|
|
|
from flask import Flask
|
2015-03-31 00:51:30 +02:00
|
|
|
from flask.ext.bootstrap import Bootstrap, StaticCDN
|
2015-03-26 21:49:14 +01:00
|
|
|
from flask.ext.sqlalchemy import SQLAlchemy
|
|
|
|
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
app.config.from_object('config.Configuration')
|
2015-03-27 21:57:37 +01:00
|
|
|
Bootstrap(app)
|
2015-03-26 21:49:14 +01:00
|
|
|
|
2015-03-31 00:51:30 +02:00
|
|
|
# use our own bootstrap theme
|
|
|
|
app.extensions['bootstrap']['cdns']['bootstrap'] = StaticCDN()
|
|
|
|
|
2015-03-26 21:49:14 +01:00
|
|
|
db = SQLAlchemy(app)
|
2015-03-31 00:06:09 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2015-03-31 16:29:28 +02:00
|
|
|
|
2015-03-31 00:06:09 +02:00
|
|
|
if not app.debug:
|
2015-03-31 15:11:20 +02:00
|
|
|
app.wsgi_app = PrefixFix(app.wsgi_app, '/james')
|