def init_app(app): webassets = Environment(app) webassets.register('apollo_css', apollo_css) webassets.register('apollo_js', apollo_js) webassets.manifest = 'cache' if not app.debug else False webassets.cache = not app.debug webassets.debug = app.debug
def init_app(app): webassets = Environment(app) webassets.register("apollo_css", apollo_css) webassets.register("apollo_js", apollo_js) webassets.manifest = "cache" if not app.debug else False webassets.cache = not app.debug webassets.debug = app.debug
def register_web_ui(mgr): global manager, assets manager = mgr assets_cache = os.path.join(manager.config_base, '.webassets-cache') if not os.path.isdir(assets_cache): os.mkdir(assets_cache) assets = Environment(webui_app) assets.directory = assets_cache for p in _get_plugin_paths(): assets.append_path(p, url="%s/plugin" % webui_app.url_path) assets.cache = assets_cache assets.url = '%s/cache' % webui_app.url_path if 'debug' in manager.args: assets.debug = True load_assets() load_ui_plugins() register_app(webui_app.url_path, webui_app) register_home('%s/' % webui_app.url_path)
def init_app(app): webassets = Environment(app) webassets.register('css_all', css_all) webassets.register('js_vendor', js_vendor) webassets.register('js_ie', js_ie) webassets.register('js_main', js_main) webassets.manifest = 'cache' if not app.debug else False webassets.cache = not app.debug webassets.debug = app.debug
def configure_static_assets(app): loader = YAMLLoader('assets.yaml') assets = Environment(app) assets.manifest = None assets.cache = False assets.directory = './makers' assets.url = '' for name, bundle in loader.load_bundles().items(): assets.register(name, bundle) app.environment = assets
def setup_bundles(app): assets_env = Environment(app) assets_env.url = '/statics' assets_env.manifest = 'file:Compiled/static-manifest-version' assets_env.cache = False assets_env.auto_build = False assets_env.debug = app.config.get('DEVELOPMENT') == True # load and register bundles config_path = app.instance_path + '/config/asset_bundles.yaml' bundles = YAMLLoader(config_path).load_bundles() for name, bundle in bundles.iteritems(): assets_env.register(name, bundle) app.assets_env = assets_env
def init(app): """ Bundle projects assets :type app: flask.Flask """ assets = Environment(app) assets.auto_build = app.config.get('ASSETS_AUTO_BUILD', True) files_to_watch = [] if 'COLLECT_STATIC_ROOT' in app.config: assets.cache = app.config['COLLECT_STATIC_ROOT'] collect = Collect() collect.init_app(app) collect.collect() app.static_folder = app.config['COLLECT_STATIC_ROOT'] if 'JS_ASSETS' in app.config and len(app.config['JS_ASSETS']) > 0: files_to_watch += [ os.path.join(app.static_folder, js_file) for js_file in app.config['JS_ASSETS'] ] js = Bundle(*app.config['JS_ASSETS'], output=app.config['JS_ASSETS_OUTPUT'], filters=app.config['JS_ASSETS_FILTERS']) assets.register('js_all', js) if 'CSS_ASSETS' in app.config and len(app.config['CSS_ASSETS']) > 0: files_to_watch += [ os.path.join(app.static_folder, css_file) for css_file in app.config['CSS_ASSETS'] ] css = Bundle(*app.config['CSS_ASSETS'], output=app.config['CSS_ASSETS_OUTPUT'], filters=app.config['CSS_ASSETS_FILTERS']) assets.register('css_all', css) app.assets = assets app._base_files_to_watch = files_to_watch
output='../static/css/multiple-select.css' ), # JAVASCRIPT 'main_js': Bundle( 'lib/multiple-select/jquery.multiple.select.js', 'js/main.js', filters='jsmin', output='../static/js/main.js' ), 'download_js': Bundle( 'js/download.js', output='../static/js/download.js', filters='jsmin' ), 'edit_js': Bundle( 'js/edit.js', output='../static/js/edit.js', filters='jsmin' ), 'search_js': Bundle( 'js/search.js', output='../static/js/search.js', filters='jsmin' ) } assets = Environment(app) assets.load_path = [abspath(join(app.root_path, 'assets'))] assets.cache = abspath(join(app.root_path, 'assets/cache')) assets.register(bundles)
from config import config, LANGUAGES from decorators import crossdomain from metrics import StatsdClient # set up flask app = Flask(__name__) app.config.from_object(__name__) app.config["STATIC_URL"] = 'static' app.config["STATIC_ROOT"] = 'static' app.config["PROPAGATE_EXCEPTIONS"] = False babel = Babel(app) # flask-assets assets = Environment(app) assets.cache = "/tmp/" assets.init_app(app) # logger logger = logging.getLogger('kilink.kilink') # metrics metrics = StatsdClient("linkode") def nocache(f): """Decorator to make a page un-cacheable.""" def new_func(*args, **kwargs): """The new function.""" resp = make_response(f(*args, **kwargs)) resp.headers['Cache-Control'] = 'public, max-age=0'
base_dir = os.path.dirname(os.path.realpath(__file__)) app.jinja_loader = FileSystemLoader(os.path.join(base_dir, 'static', 'templates')) app.config.from_object('config') app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI db = SQLAlchemy(app) lm = LoginManager() lm.init_app(app) lm.login_view = 'login' lm.login_message = 'Please log in to access this page.' mail = Mail(app) CsrfProtect(app) assets = Environment(app) assets.cache = False assets.manifest = "json:{path}" appcss = Bundle('css/fix.css', 'css/custom.css', 'css/navbar.css', 'css/fonts.css', 'css/font-awesome.min.css', filters='cssmin', output='gen/app.css') assets.register('css_app', appcss) appjs = Bundle('js/data.js', 'js/app.js', 'js/navbar.js', filters='jsmin', output='gen/app.js') libsjs = Bundle('js/_libs/jquery/jquery-2.2.0.min.js', 'js/_libs/nunjucks.min.js', 'js/_libs/canvas-to-blob.min.js', 'js/_libs/load-image.all.min.js', 'js/_libs/backbone/underscore-min.js', 'js/_libs/backbone/backbone-min.js', 'js/_libs/backbone/backbone.localStorage-min.js', filters='jsmin', output='gen/libs.js') assets.register('js_app', appjs) assets.register('js_libs', libsjs) app.config['OAUTH_CREDENTIALS'] = {
app.jinja_loader = FileSystemLoader( os.path.join(base_dir, 'static', 'templates')) app.config.from_object('config') app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI db = SQLAlchemy(app) lm = LoginManager() lm.init_app(app) lm.login_view = 'login' lm.login_message = 'Please log in to access this page.' mail = Mail(app) CsrfProtect(app) assets = Environment(app) assets.cache = False assets.manifest = "json:{path}" appcss = Bundle('css/fix.css', 'css/custom.css', 'css/fonts.css', filters='cssmin', output='gen/app.css') assets.register('css_app', appcss) appjs = Bundle('js/data.js', 'js/main.js', filters='jsmin', output='gen/app.js') libsjs = Bundle('js/_libs/jquery/jquery-2.2.0.min.js', 'js/_libs/nunjucks.min.js',
locale.setlocale(locale.LC_ALL, '') # configuration SECRET_KEY = 'development key' CACHE_TYPE = 'null' CACHE_DIR = '_cache' CACHE_THRESHOLD = 100 LOGGING_FILE = 'c2cstats.log' app = Flask(__name__) app.config.from_object(__name__) app.config.from_envvar('C2CSTATS_SETTINGS', silent=True) cache = Cache(app) assets = Environment(app) assets.cache = os.path.join(app.config['CACHE_DIR'], 'assets') # logging config if not app.debug: import logging file_handler = logging.FileHandler(app.config['LOGGING_FILE']) file_handler.setFormatter(logging.Formatter( '%(asctime)s %(levelname)s: %(message)s [in %(filename)s:%(lineno)d]')) app.logger.addHandler(file_handler) app.logger.setLevel(logging.INFO) @app.route('/') def index(): return render_template('index.html')
from modules.database import get_mysql from modules.models import ( page, proxy, result, statistics_memory, statistics_request, ) from modules.log import initialize initialize() application = Flask( __name__, static_folder=join(abspath(dirname(__file__)), 'resources'), ) application.config.from_pyfile('settings.py') assets = Environment(application) assets.cache = not application.config['DEBUG'] assets.debug = application.config['DEBUG'] assets.directory = application.static_folder assets.manifest = 'json:assets/versions.json' assets.url = application.static_url_path assets.url_expire = True assets.versions = 'hash' assets.register('javascripts', Bundle( 'vendor/jquery/dist/jquery.js', 'vendor/angular/angular.min.js', 'vendor/bootstrap/dist/js/bootstrap.js', 'vendor/highcharts/highcharts-all.js', 'javascripts/all.js', filters='rjsmin' if not application.config['DEBUG'] else None, output='assets/compressed.js', ))
from os.path import dirname, join, realpath, normpath from flask.ext.assets import Environment, Bundle from app import app environment = Environment(app) environment.versions = 'hash' manifest_path = normpath(realpath(join(dirname(__file__), '.static-manifest'))) environment.manifest = 'file:%s' % manifest_path environment.cache = False environment.debug = False css_main = Bundle('css/main.css', Bundle('less/main.less', filters='less'), filters='cssmin', output='css/main.%(version)s.css') js_head = Bundle( 'https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js', output='js/head.%(version)s.js') js_foot = Bundle( 'https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js', Bundle('js/scripts.js', filters='jsmin'), output='js/main.%(version)s.js')
'db1': app.config['SQLALCHEMY_DATABASE_URI'], } root_path = os.path.abspath("%s/.." % os.path.dirname(__file__)) tmp_path = "%s/tmp" % root_path os.environ['BOTO_ENDPOINTS'] = os.path.abspath( "%s/config/boto_endpoints.json" % root_path) ################### # ASSETS SETTINGS # ################### assets = Environment(app) loader = YAMLLoader("%s/assets/assets.yml" % root_path) bundles = loader.load_bundles() assets.register(bundles) assets.set_directory("%s/public" % root_path) assets.load_path.append('./assets/') assets.url = '/' assets.manifest = "json:%s/public/gen/webassets-manifest.json" % root_path development_mode = not environment.equals('production') assets.cache = development_mode assets.auto_build = development_mode assets.debug = development_mode # MD Feb-2015 Allow created files to be group writeable. This will fix some problems with files created in the /tmp # directory that are accessed both by Celery and duesty scripts. The /tmp directory should have set "chmod g+s tmp" os.umask(0o002)
from os.path import dirname, join, realpath, normpath from flask.ext.assets import Environment, Bundle from app import app environment = Environment(app) environment.versions = 'hash' manifest_path = normpath(realpath(join(dirname(__file__), '.static-manifest'))) environment.manifest = 'file:%s' % manifest_path environment.cache = False environment.debug = False css_main = Bundle( 'css/main.css', Bundle('less/main.less', filters='less'), filters='cssmin', output='css/main.%(version)s.css' ) js_head = Bundle( 'https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js', output='js/head.%(version)s.js' ) js_foot = Bundle( 'https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js', Bundle( 'js/scripts.js',