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


Python livereload.Server方法代码示例

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


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

示例1: livereload

# 需要导入模块: import livereload [as 别名]
# 或者: from livereload import Server [as 别名]
def livereload(ctx):
    """Automatically reload browser tab upon file modification."""
    from livereload import Server
    server = Server()
    # Watch the base settings file
    server.watch(CONFIG['settings_base'], lambda: build(ctx))
    # Watch content source files
    content_file_extensions = ['.md', '.rst']
    for extension in content_file_extensions:
        content_blob = '{0}/**/*{1}'.format(SETTINGS['PATH'], extension)
        server.watch(content_blob, lambda: build(ctx))
    # Watch the theme's templates and static assets
    theme_path = SETTINGS['THEME']
    server.watch('{}/templates/*.html'.format(theme_path), lambda: build(ctx))
    static_file_extensions = ['.css', '.js']
    for extension in static_file_extensions:
        static_file = '{0}/static/**/*{1}'.format(theme_path, extension)
        server.watch(static_file, lambda: build(ctx))
    # Serve output path on configured port
    server.serve(port=CONFIG['port'], root=CONFIG['deploy_path'])

#################################################################################################### 
开发者ID:FabriceSalvaire,项目名称:PySpice,代码行数:24,代码来源:tasks.py

示例2: on_serve

# 需要导入模块: import livereload [as 别名]
# 或者: from livereload import Server [as 别名]
def on_serve(self, server: Server, config: Config, builder: Callable = None, **kwargs) -> Server:
        """
        Hook for the [`on_serve` event](https://www.mkdocs.org/user-guide/plugins/#on_serve).

        In this hook, we add the directories specified in the plugin's configuration to the list of directories
        watched by `mkdocs`. Whenever a change occurs in one of these directories, the documentation is built again
        and the site reloaded.
        """
        if builder is None:
            # The builder parameter was added in mkdocs v1.1.1.
            # See issue https://github.com/mkdocs/mkdocs/issues/1952.
            builder = list(server.watcher._tasks.values())[0]["func"]
        for element in self.config["watch"]:
            log.debug(f"mkdocstrings.plugin: Adding directory '{element}' to watcher")
            server.watch(element, builder)
        return server 
开发者ID:pawamoy,项目名称:mkdocstrings,代码行数:18,代码来源:plugin.py

示例3: handle

# 需要导入模块: import livereload [as 别名]
# 或者: from livereload import Server [as 别名]
def handle(self, *args, **options):
        m = re.match(naiveip_re, options['addrport'])
        if m is None:
            raise CommandError('"%s" is not a valid port number '
                               'or address:port pair.' % options['addrport'])
        addr, _ipv4, _ipv6, _fqdn, port = m.groups()
        if not port.isdigit():
            raise CommandError("%r is not a valid port number." % port)

        if addr:
            if _ipv6:
                raise CommandError('IPv6 addresses are currently not supported.')


        application = get_internal_wsgi_application()
        server = Server(application)

        for file in os.listdir('.'):
            if file[0] != '.' and file[:2] != '__' and os.path.isdir(file):
                server.watch(file)

        server.serve(host=addr, port=port, liveport=options['liveport']) 
开发者ID:V1EngineeringInc,项目名称:V1EngineeringInc-Docs,代码行数:24,代码来源:livereload.py

示例4: start_livereload

# 需要导入模块: import livereload [as 别名]
# 或者: from livereload import Server [as 别名]
def start_livereload(self):
        from livereload import Server

        server = Server()
        for path in settings.STATICFILES_DIRS:
            server.watch(path)
        for path in settings.TEMPLATES[0]["DIRS"]:
            server.watch(path)
        server.serve(port=settings.LIVERELOAD_PORT) 
开发者ID:archesproject,项目名称:arches,代码行数:11,代码来源:developer.py

示例5: live

# 需要导入模块: import livereload [as 别名]
# 或者: from livereload import Server [as 别名]
def live():
    """Run livereload server"""
    from livereload import Server

    server = Server(app)

    map(server.watch, glob2.glob("application/pages/**/*.*"))  # pages
    map(server.watch, glob2.glob("application/macros/**/*.html"))  # macros
    map(server.watch, glob2.glob("application/static/**/*.*"))  # public assets

    server.serve(port=PORT) 
开发者ID:Akagi201,项目名称:learning-python,代码行数:13,代码来源:manage.py

示例6: _livereload

# 需要导入模块: import livereload [as 别名]
# 或者: from livereload import Server [as 别名]
def _livereload(host, port, config, builder, site_dir):

    # We are importing here for anyone that has issues with livereload. Even if
    # this fails, the --no-livereload alternative should still work.
    _init_asyncio_patch()
    from livereload import Server
    import livereload.handlers

    class LiveReloadServer(Server):

        def get_web_handlers(self, script):
            handlers = super().get_web_handlers(script)
            # replace livereload handler
            return [(handlers[0][0], _get_handler(site_dir, livereload.handlers.StaticFileHandler), handlers[0][2],)]

    server = LiveReloadServer()

    # Watch the documentation files, the config file and the theme files.
    server.watch(config['docs_dir'], builder)
    server.watch(config['config_file_path'], builder)

    for d in config['theme'].dirs:
        server.watch(d, builder)

    # Run `serve` plugin events.
    server = config['plugins'].run_event('serve', server, config=config, builder=builder)

    server.serve(root=site_dir, host=host, port=port, restart_delay=0) 
开发者ID:mkdocs,项目名称:mkdocs,代码行数:30,代码来源:serve.py

示例7: serve

# 需要导入模块: import livereload [as 别名]
# 或者: from livereload import Server [as 别名]
def serve(host, port, debug, livereload, test):
    """Start the web server."""
    pymongo_config = dict(
        MONGO_HOST=current_app.config.get("MONGO_HOST", "localhost"),
        MONGO_PORT=current_app.config.get("MONGO_PORT", 27017),
        MONGO_DBNAME=current_app.config.get("MONGO_DBNAME", "scout"),
        MONGO_USERNAME=current_app.config.get("MONGO_USERNAME", None),
        MONGO_PASSWORD=current_app.config.get("MONGO_PASSWORD", None),
    )

    valid_connection = check_connection(
        host=pymongo_config["MONGO_HOST"],
        port=pymongo_config["MONGO_PORT"],
        username=pymongo_config["MONGO_USERNAME"],
        password=pymongo_config["MONGO_PASSWORD"],
        authdb=current_app.config.get("MONGO_DBNAME", "scout"),
    )

    LOG.info("Test if mongod is running")
    if not valid_connection:
        LOG.warning("Connection could not be established")
        LOG.info("Is mongod running?")
        raise click.Abort()

    if test:
        LOG.info("Connection could be established")
        return

    if livereload:
        server = Server(current_app.wsgi_app)
        server.serve(host=host, port=port, debug=debug)
    else:
        return run_simple(
            hostname=host,
            port=port,
            application=current_app,
            use_reloader=False,
            use_debugger=debug,
        ) 
开发者ID:Clinical-Genomics,项目名称:scout,代码行数:41,代码来源:serve.py

示例8: main

# 需要导入模块: import livereload [as 别名]
# 或者: from livereload import Server [as 别名]
def main():
    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s - %(message)s',
                        datefmt='%Y-%m-%d %H:%M:%S')

    (options, args) = parse_options()

    port = options.port
    assets_path = options.path
    file_prefix = options.prefix
    host_address = options.host_address

    csv.register_dialect('custom_delimiter', delimiter=options.delimiter)

    card_renderer = CardRenderer(assets_path, file_prefix)

    observer = Observer()
    observer.schedule(LoggingEventHandler(), assets_path, recursive=True)
    observer.schedule(RenderingEventHandler(card_renderer), assets_path, recursive=True)

    card_renderer.render_cards()

    observer.start()

    server = Server()
    server.watch(card_renderer.all_cards_rendered_path)
    server.serve(root=assets_path, port=port, host=host_address)

    observer.stop()
    observer.join() 
开发者ID:ghostsquad,项目名称:pycard,代码行数:32,代码来源:pycard.py

示例9: _livereload

# 需要导入模块: import livereload [as 别名]
# 或者: from livereload import Server [as 别名]
def _livereload(host, port, config, builder, site_dir):

    # We are importing here for anyone that has issues with livereload. Even if
    # this fails, the --no-livereload alternative should still work.
    _init_asyncio_patch()
    from livereload import Server
    import livereload.handlers

    class LiveReloadServer(Server):

        def get_web_handlers(self, script):
            handlers = super().get_web_handlers(script)
            # replace livereload handler
            return [(handlers[0][0], _get_handler(site_dir, livereload.handlers.StaticFileHandler), handlers[0][2],)]

    server = LiveReloadServer()

    # Watch the documentation files, the config file and the theme files.
    server.watch(config['docs_dir'], builder)
    server.watch(config['config_file_path'], builder)

    for d in config['theme'].dirs:
        server.watch(d, builder)

    # Run `serve` plugin events.
    server = config['plugins'].run_event('serve', server, config=config)

    server.serve(root=site_dir, host=host, port=port, restart_delay=0) 
开发者ID:V1EngineeringInc,项目名称:V1EngineeringInc-Docs,代码行数:30,代码来源:serve.py


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