def create_app(): app = Flask(__name__) app.config.from_pyfile('settings.py') init_models(app) init_views(app) init_loginmanager(app) init_bootstrap(app) return app
app.jinja_env.filters['u_files'] = upload_files app.config.update( SQLALCHEMY_DATABASE_URI = config.DATABASE_URI, SQLALCHEMY_POOL_SIZE = 1000, SQLALCHEMY_POOL_TIMEOUT = 10, SQLALCHEMY_POOL_RECYCLE = 3600, SESSION_COOKIE_DOMAIN = config.SESSION_COOKIE_DOMAIN, MAX_CONTENT_LENGTH = config.MAX_CONTENT_LENGTH, ) logger = logging.getLogger(__name__) init_db(app) init_views(app) csrf(app) app.wsgi_app = SessionMiddleware(app.wsgi_app, \ FilesystemSessionStore(), \ cookie_name=config.SESSION_KEY, cookie_path='/', \ cookie_domain=config.SESSION_COOKIE_DOMAIN) @app.route('/') @check_ua def index(): return render_template('index.html') @app.before_request def before_request(): g.session = request.environ['xiaomen.session'] g.current_user = get_current_user()
parser.add_argument("-r", "--reloader", action="store_true", help="Use flask reloader.") args = parser.parse_args() return args if __name__ == '__main__': # Parse cli args args = parseargs() log = set_log(args, sys.stdout, sys.stderr) # Apply routing & auth deco to views init_views() app.run(debug=args.debug, use_reloader=args.reloader, host=settings.__instance_host__, port=settings.__instance_port__,) else: # Invocation by apache mod_wsgi # Setup file logger, flask context exceptions will be # written to the handler # # TODO - ensure perms exist from logging import FileHandler, Formatter
"--reloader", action="store_true", help="Use flask reloader.") args = parser.parse_args() return args if __name__ == '__main__': # Parse cli args args = parseargs() log = set_log(args, sys.stdout, sys.stderr) # Apply routing & auth deco to views init_views() app.run( debug=args.debug, use_reloader=args.reloader, host=settings.__instance_host__, port=settings.__instance_port__, ) else: # Invocation by apache mod_wsgi # Setup file logger, flask context exceptions will be # written to the handler # # TODO - ensure perms exist
app.debug = config.DEBUG app.secret_key = config.SECRET_KEY app.jinja_env.filters['s_files'] = static_files app.jinja_env.filters['u_files'] = upload_files app.config.update( SQLALCHEMY_DATABASE_URI=config.DATABASE_URI, SQLALCHEMY_POOL_SIZE=1000, SQLALCHEMY_POOL_TIMEOUT=10, SQLALCHEMY_POOL_RECYCLE=3600, SESSION_COOKIE_DOMAIN=config.SESSION_COOKIE_DOMAIN, MAX_CONTENT_LENGTH=config.MAX_CONTENT_LENGTH, ) init_db(app) init_views(app) csrf(app) app.wsgi_app = SessionMiddleware( app.wsgi_app, \ RedisSessionStore( key_template=config.SESSION_KEY_TEMPLE,\ expire=config.SESSION_EXPIRE, \ salt=config.SESSION_SALT, \ pool=common.session_pool), cookie_name=config.SESSION_KEY, \ cookie_age=config.COOKIE_MAX_AGE, \ cookie_path='/', \ cookie_expires=None, \ cookie_secure=None, \ cookie_httponly=False, \