当前位置: 首页>>代码示例>>Python>>正文


Python Environment.url方法代码示例

本文整理汇总了Python中flask_assets.Environment.url方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.url方法的具体用法?Python Environment.url怎么用?Python Environment.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_assets.Environment的用法示例。


在下文中一共展示了Environment.url方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: install

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
    def install(cls, app):
        """Install the extension into the application."""
        Environment.resolver_class = InvenioResolver
        env = Environment(app)
        env.url = "{0}/{1}/".format(app.static_url_path,
                                    app.config["ASSETS_BUNDLES_DIR"])
        env.directory = os.path.join(app.static_folder,
                                     app.config["ASSETS_BUNDLES_DIR"])
        env.append_path(app.static_folder)
        env.auto_build = app.config.get("ASSETS_AUTO_BUILD", True)

        # The filters less and requirejs don't have the same behaviour by
        # default. Make sure we are respecting that.
        app.config.setdefault("LESS_RUN_IN_DEBUG", True)
        app.config.setdefault("REQUIREJS_RUN_IN_DEBUG", False)
        # Fixing some paths as we forced the output directory with the
        # .directory
        app.config.setdefault("REQUIREJS_BASEURL", app.static_folder)
        requirejs_config = os.path.join(env.directory,
                                        app.config["REQUIREJS_CONFIG"])
        if not os.path.exists(requirejs_config):
            app.config["REQUIREJS_CONFIG"] = os.path.relpath(
                os.path.join(app.static_folder,
                             app.config["REQUIREJS_CONFIG"]),
                env.directory)

        app.jinja_env.add_extension(BundleExtension)
        app.context_processor(BundleExtension.inject)
开发者ID:Theer108,项目名称:invenio,代码行数:30,代码来源:extensions.py

示例2: register_assets

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
def register_assets(app):
	assets = Environment(app)
	assets.url = app.static_url_path
	assets.directory = app.static_folder
	assets.append_path('assets')
	scss = Bundle('scss/main.scss', filters='pyscss', output='main.css', depends=('scss/*.scss'))
	assets.register('scss_all', scss)
开发者ID:MatthewJA,项目名称:govhack-2016,代码行数:9,代码来源:assets.py

示例3: init_app

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
def init_app(app):
    webassets = Environment(app)
    webassets.url = app.static_url_path
    webassets.register('js_lodjers', js_lodjers)
    webassets.register('js_mixpanel', js_mixpanel)
    webassets.register('css_lodjers', css_lodjers)
    webassets.manifest = 'cache' if not app.debug else False
    webassets.cache = not app.debug
    webassets.debug = app.debug
开发者ID:alexgerstein,项目名称:dartmouth-roommates,代码行数:11,代码来源:assets.py

示例4: init_app

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
def init_app(app):
    webassets = Environment(app)
    webassets.url = app.static_url_path
    webassets.register('css_all', css_all)
    webassets.register('js_vendor', js_vendor)
    webassets.register('js_main', js_main)
    webassets.manifest = 'cache' if not app.debug else False
    webassets.cache = not app.debug
    webassets.debug = app.debug
开发者ID:adamwen829,项目名称:vilya,代码行数:11,代码来源:assets.py

示例5: register_assets

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
def register_assets(app):
    assets = Environment(app)
    assets.debug = app.debug
    assets.auto_build = True
    assets.url = app.static_url_path

    css_all = Bundle(*CSS_ASSETS, filters='cssmin', output='css/bundle.min.css')

    assets.register('css_all', css_all)
    app.logger.info("Registered assets...")
    return assets
开发者ID:Alben26,项目名称:Zimbra_administration,代码行数:13,代码来源:assets.py

示例6: init_app

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
def init_app(app):
    """
    Initilize assets.
    :param app:
    """
    webassets = Environment(app)
    webassets.url = app.static_url_path
    webassets.register('css_all', css_all)
    webassets.manifest = 'cache' if not app.debug else False
    webassets.cache = not app.debug
    webassets.debug = app.debug
开发者ID:iepathos,项目名称:flask-canjs-i18n-boilerplate,代码行数:13,代码来源:assets.py

示例7: init_app

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
def init_app(app, allow_auto_build=True):
    assets = Environment(app)
    # on google app engine put manifest file beside code
    # static folders are stored separately and there is no access to them in production
    folder = os.path.abspath(os.path.dirname(__file__)) if "APPENGINE_RUNTIME" in os.environ else ""
    assets.directory = os.path.join(app.static_folder, "compressed")
    assets.manifest = "json:{}/manifest.json".format(assets.directory)
    assets.url = app.static_url_path + "/compressed"
    compress = not app.debug  # and False
    assets.debug = not compress
    assets.auto_build = compress and allow_auto_build
    assets.register('js', Bundle(*JS, filters='yui_js', output='script.%(version)s.js'))
    assets.register('css', Bundle(*CSS, filters='yui_css', output='style.%(version)s.css'))
开发者ID:wooyek,项目名称:glosuj-w-lomiankach,代码行数:15,代码来源:assets.py

示例8: register_assets

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
def register_assets(app):
    assets = Environment(app)
    assets.debug = app.debug
    assets.auto_build = True
    assets.url = app.static_url_path

    css_blog = Bundle(*BLOG_ASSETS, filters='cssmin', output='css/blog.min.css')
    css_welcome = Bundle(*INDEX_ASSETS, filters='cssmin', output='css/welcome.min.css')

    js_all = Bundle(*JS_ASSETS, filters='rjsmin', output='js/all.min.js')

    assets.register('css_blog', css_blog)
    assets.register('css_welcome', css_welcome)
    assets.register('js_all', js_all)
    app.logger.info("Registered assets...")

    return assets
开发者ID:nezaj,项目名称:portfolio,代码行数:19,代码来源:assets.py

示例9: assets

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
def assets(app):
    environment = Environment(app)
    environment.url = "/static"
    # environment.config['COMPASS_CONFIG'] = {"sass_dir": environment.directory+"../../assets/sass"}
    # print(environment.directory)

    css_main = Bundle(assets_folder + 'sass/app.scss', filters='scss' if app.debug else 'scss,cssmin', depends=(assets_folder + 'sass/*.scss', assets_folder + 'sass/**/*.scss'), output='css/gen/main.%(version)s.css')
    environment.register('css_main', css_main)

    js_base = Bundle(assets_folder + 'js/vendor/custom.modernizr.js',
                     assets_folder + 'js/junction/molecular.js',
                     assets_folder + 'js/vendor/jquery.js',
                     assets_folder + 'js/vendor/jquery.multi-select.js',
                     assets_folder + 'js/vendor/angular.js',
                     assets_folder + 'js/vendor/typeahead.js',
                     # assets_folder + 'js/vendor/snowstorm.js',
                     assets_folder + 'js/foundation/foundation.js',
                     assets_folder + 'js/foundation/foundation.topbar.js',
                     assets_folder + 'js/foundation/foundation.dropdown.js',
                     assets_folder + 'js/foundation/foundation.abide.js',
                     assets_folder + 'js/foundation/foundation.joyride.js',
                     assets_folder + 'js/foundation/foundation.orbit.js',
                     assets_folder + 'js/foundation/foundation.tab.js',
                     assets_folder + 'js/foundation/foundation.reveal.js',
                     assets_folder + 'js/foundation/foundation.alert.js',
                     assets_folder + 'js/foundation/foundation.tooltip.js',
                     assets_folder + 'js/foundation/foundation.accordion.js',
                     assets_folder + 'js/junction/editable.js',
                     assets_folder + 'js/junction/notifications.js',
                     assets_folder + 'js/junction/app.js')
    js_main = Bundle(js_base, filters=None if app.debug else 'rjsmin', output='js/gen/app.%(version)s.js')
    environment.register('js_main', js_main)

    js_graphs = Bundle(assets_folder + 'js/vendor/d3.js',
                       assets_folder + 'js/junction/alts_graph.js',
                       filters=None, output='js/gen/graphs.%(version)s.js')
    environment.register('js_graphs', js_graphs)

    return environment
开发者ID:JunctionAt,项目名称:JunctionWWW,代码行数:41,代码来源:assets.py

示例10: Object

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
import pandas as pd
import dateutil

class Object(object):
    """ This class does not do anything"""
    pass

app = Flask(__name__)

DATABASE = os.path.join(app.root_path, 'static/data/scanntronicDaten.sqlite'),

######################################################################
#  Compile scss files
######################################################################
assets = Environment(app)
assets.url = app.static_url_path
scss = Bundle('../assets/scss/nav_bar.scss', filters='pyscss', output='css/nav_bar.css')
assets.register('scss_all', scss)

# Sensoren
list_sensors = ['Riss Integraler Stoss',
                'Riss Mitte',
                'Hygro Integraler Stoss',
                'Hygro Mitte',
                ]

list_url = ['riss_integraler_stoss',
            'riss_mitte',
            'hygro_integraler_stoss',
            'hygro_mitte',
            ]
开发者ID:Stuttgarter-Bruecke,项目名称:monitoring-webseite,代码行数:33,代码来源:app.py

示例11: __init__

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import url [as 别名]
    def __init__(self, server, cfg_manager):
        core_server_url  = cfg_manager.get_value( 'core_server_url', '' )
        self.script_name = urlparse.urlparse(core_server_url).path.split('/weblab')[0] or ''
        force_host_name = cfg_manager.get_value( 'force_host_name', False)

        url_plus_weblab = self.script_name + '/weblab/'

        self.app = Flask('weblab.core.wl')
        if force_host_name:
            self.app.wsgi_app = ForceHostFix(self.app, core_server_url)
        else:
            self.app.wsgi_app = ProxyFix(self.app.wsgi_app)

        self.app.config['SECRET_KEY'] = os.urandom(32)
        self.app.config['APPLICATION_ROOT'] = self.script_name
        self.app.config['SESSION_COOKIE_PATH'] = url_plus_weblab
        self.app.config['SESSION_COOKIE_NAME'] = 'weblabsession'
        env = Environment(self.app)
        env.url = url_plus_weblab + 'static/'

        # Initialize internationalization code.
        self.babel = initialize_i18n(self.app)

        # Mostly for debugging purposes, this snippet will print the site-map so that we can check
        # which methods we are routing.
        @self.app.route("/site-map")
        def site_map():
            lines = []
            for rule in self.app.url_map.iter_rules():
                line = str(escape(repr(rule)))
                lines.append(line)

            ret = "<br>".join(lines)
            return ret


        flask_debug = cfg_manager.get_value('flask_debug', False)
        core_facade_port = cfg_manager.get_value(configuration_doc.CORE_FACADE_PORT, 'unknown')
        if flask_debug and not is_testing():
            print("*" * 50, file=sys.stderr)
            print("WARNING " * 5, file=sys.stderr)
            print("flask_debug is set to True. This is an important security leak. Do not use it in production, only for bugfixing!!!", file=sys.stderr)
            print("If you want to see the debug toolbar in Flask pages, also use http://localhost:{0}/weblab/".format(core_facade_port), file=sys.stderr)
            print("WARNING " * 5, file=sys.stderr)
            print("*" * 50, file=sys.stderr)
        self.app.config['DEBUG'] = flask_debug
        if os.path.exists('logs'):
            f = os.path.join('logs','admin_app.log')
        else:
            f = 'admin_app.log'

        formatter = logging.Formatter("[%(asctime)s] %(levelname)s - %(message)s")

        file_handler = RotatingFileHandler(f, maxBytes = 50 * 1024 * 1024)
        file_handler.setLevel(logging.WARNING)
        file_handler.setFormatter(formatter)
        self.app.logger.addHandler(file_handler)
        stream_handler = logging.StreamHandler()
        stream_handler.setLevel(logging.WARNING)
        stream_handler.setFormatter(formatter)
        self.app.logger.addHandler(stream_handler)

        super(WebLabFlaskServer, self).__init__(cfg_manager, self.app)

        json_api = Blueprint('json', __name__)
        weblab_api.apply_routes_api(json_api, server)
        self.app.register_blueprint(json_api, url_prefix = '/weblab/json')
        self.app.register_blueprint(json_api, url_prefix = '/weblab/login/json')
 
        authn_web = Blueprint('login_web', __name__)
        weblab_api.apply_routes_login_web(authn_web, server)
        self.app.register_blueprint(authn_web, url_prefix = '/weblab/login/web')

        static_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), 'static'))
        core_web = Blueprint('core_web', __name__, static_folder=static_folder)
        weblab_api.apply_routes_web(core_web, server)
        self.app.register_blueprint(core_web, url_prefix = '/weblab/web')

        # Register the blueprint for the new (year 2015) flask-based web client.
        # The .apply_routes_webclient method is dynamically generated, the name matches
        # that in the wl.py module.
        # Attempt at setting the right static folder.
        core_webclient = Blueprint('core_webclient', __name__, static_folder=static_folder)
        weblab_api.apply_routes_webclient(core_webclient, server)
        self.app.register_blueprint(core_webclient, url_prefix = '/weblab')

        @self.app.context_processor
        def inject_weblab_api():
            return dict(weblab_api=weblab_api, display_date=display_date, get_locale=get_locale, wl_config=cfg_manager)

        self.admin_app = AdministrationApplication(self.app, cfg_manager, server)

        if flask_debug:
            from flask_debugtoolbar import DebugToolbarExtension
            toolbar = DebugToolbarExtension()
            toolbar.init_app(self.app)
            self.app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False
开发者ID:labsland,项目名称:weblabdeusto,代码行数:99,代码来源:server.py


注:本文中的flask_assets.Environment.url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。