Esempio n. 1
0
 def handle_noargs(self, **options):
     server = Server()
     pathlist = []
     # Find statics/templates directories of all installed apps
     for app in settings.INSTALLED_APPS:
         try:
             mod = import_module(app)
         except ImportError as e:
             raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
         staticfiles_dir = os.path.join(os.path.dirname(mod.__file__),
                                        'statics')
         templates_dir = os.path.join(os.path.dirname(mod.__file__),
                                      'templates')
         if os.path.isdir(staticfiles_dir):
             pathlist.append("{}".format(staticfiles_dir))
         if os.path.isdir(templates_dir):
             pathlist.append("{}".format(templates_dir))
     # STATICFILES_DIRS, TEMPLATE_DIRS
     for path in settings.STATICFILES_DIRS:
         pathlist.append("{}".format(path))
     for path in settings.TEMPLATE_DIRS:
         pathlist.append("{}".format(path))
     print('Start livereloading with followings...')
     for path in pathlist:
         print('- {}'.format(path))
         server.watch(path)
     # Listen 35729 which is a common port for LiveReload browser ext.
     server.serve(port=35729)
Esempio n. 2
0
    def do(self, *args):
        """Run Django with ImportD."""
        for bp in self.blueprint_list:
            self._apply_blueprint(bp)

        if not args:
            args = sys.argv[1:]

        if len(args) == 0:
            return self._handle_management_command(
                self._get_runserver_cmd(), "8000")

        if 'livereload' in sys.argv:
            if not hasattr(self, "lr"):
                print("Livereload setting, lr not configured.")
                return
            from livereload import Server
            server = Server(self)
            for pat, cmd in self.lr.items():
                parts = pat.split(",")
                for part in parts:
                    server.watch(part, cmd)
            server.serve(port=8000)
            return

        return self._act_as_manage(*args)
Esempio n. 3
0
    def _execute(self, options, args):
        """Start the watcher."""
        try:
            from livereload import Server
        except ImportError:
            req_missing(['livereload>=2.0.0'], 'use the "auto" command')
            return

        # Run an initial build so we are uptodate
        subprocess.call(("nikola", "build"))

        port = options and options.get('port')

        server = Server()
        server.watch('conf.py')
        server.watch('themes/')
        server.watch('templates/')
        server.watch(self.site.config['GALLERY_PATH'])
        for item in self.site.config['post_pages']:
            server.watch(os.path.dirname(item[0]))
        for item in self.site.config['FILES_FOLDERS']:
            server.watch(os.path.dirname(item))

        out_folder = self.site.config['OUTPUT_FOLDER']
        if options and options.get('browser'):
            webbrowser.open('http://localhost:{0}'.format(port))

        server.serve(port, None, out_folder)
Esempio n. 4
0
def server(ctx, host=None, port=5000, debug=True, live=False, gitlogs=False):
    """Run the app server."""
    if gitlogs:
        git_logs(ctx)
    from website.app import init_app

    os.environ["DJANGO_SETTINGS_MODULE"] = "api.base.settings"
    app = init_app(set_backends=True, routes=True)
    settings.API_SERVER_PORT = port

    if live:
        from livereload import Server

        server = Server(app.wsgi_app)
        server.watch(os.path.join(HERE, "website", "static", "public"))
        server.serve(port=port)
    else:
        if settings.SECURE_MODE:
            context = (settings.OSF_SERVER_CERT, settings.OSF_SERVER_KEY)
        else:
            context = None
        app.run(
            host=host,
            port=port,
            debug=debug,
            threaded=debug,
            extra_files=[settings.ASSET_HASH_PATH],
            ssl_context=context,
        )
Esempio n. 5
0
def serve():
    from livereload import Server
    watcher = FileWatcher()
    watcher.watch('web')
    watcher.watch('templates')
    server = Server(app, watcher)
    server.serve(port=8000)
Esempio n. 6
0
def run():
    server = Server(app.wsgi_app)
    server.watch('app/*.py')
    server.watch('app/templates/*.html')
    server.watch('app/static/css/*.css')
    server.watch('app/static/js/*.js')
    server.serve(host='0.0.0.0')
Esempio n. 7
0
def serve(context, config, host, port, debug, livereload):
    """Start the web server."""
    pymongo_config = dict(
        MONGO_HOST=context.obj['host'],
        MONGO_PORT=context.obj['port'],
        MONGO_DBNAME=context.obj['mongodb'],
        MONGO_USERNAME=context.obj['username'],
        MONGO_PASSWORD=context.obj['password'],
    )
    
    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=context.obj['authdb'],
        )

    log.info("Test if mongod is running")
    if not valid_connection:
        log.warning("Connection could not be established")
        log.info("Is mongod running?")
        context.abort()
    

    config = os.path.abspath(config) if config else None
    app = create_app(config=pymongo_config, config_file=config)
    if livereload:
        server = Server(app.wsgi_app)
        server.serve(host=host, port=port, debug=debug)
    else:
        app.run(host=host, port=port, debug=debug)
Esempio n. 8
0
def serve(config):
    """
    Start the devserver, and rebuild the docs whenever any changes take effect.
    """
    # Create a temporary build directory, and set some options to serve it
    tempdir = tempfile.mkdtemp()
    config['site_dir'] = tempdir

    def builder():
        build(config, live_server=True)

    # Perform the initial build
    builder()

    server = Server()

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

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

    host, port = config['dev_addr'].split(':', 1)
    server.serve(root=tempdir, host=host, port=int(port), restart_delay=0)
Esempio n. 9
0
def main():
    parser = get_parser()
    args = parser.parse_args()

    srcdir = os.path.realpath(args.sourcedir)
    outdir = os.path.realpath(args.outdir)

    build_args = []
    for arg, meta in SPHINX_BUILD_OPTIONS:
        val = getattr(args, arg)
        if not val:
            continue
        opt = '-{}'.format(arg)
        if meta is None:
            build_args.extend([opt] * val)
        else:
            for v in val:
                build_args.extend([opt, v])

    build_args.extend([srcdir, outdir])
    build_args.extend(args.filenames)

    ignored = []
    if args.w:  # Logfile
        ignored.append(os.path.realpath(args.w[0]))
    if args.d:  # Doctrees
        ignored.append(os.path.realpath(args.d[0]))

    if not os.path.exists(outdir):
        os.makedirs(outdir)

    server = Server(watcher=LivereloadWatchdogWatcher())
    server.watch(srcdir, SphinxBuilder(outdir, build_args, ignored))
    server.watch(outdir)
    server.serve(port=args.port, root=outdir)
Esempio n. 10
0
File: auto.py Progetto: rghv/nikola
    def _execute(self, options, args):
        """Start the watcher."""
        try:
            from livereload import Server
        except ImportError:
            req_missing(["livereload==2.1.0"], 'use the "auto" command')
            return

        # Run an initial build so we are up-to-date
        subprocess.call(("nikola", "build"))

        port = options and options.get("port")

        server = Server()
        server.watch("conf.py", "nikola build")
        server.watch("themes/", "nikola build")
        server.watch("templates/", "nikola build")
        server.watch(self.site.config["GALLERY_PATH"], "nikola build")
        for item in self.site.config["post_pages"]:
            server.watch(os.path.dirname(item[0]), "nikola build")
        for item in self.site.config["FILES_FOLDERS"]:
            server.watch(item, "nikola build")

        out_folder = self.site.config["OUTPUT_FOLDER"]
        if options and options.get("browser"):
            webbrowser.open("http://localhost:{0}".format(port))

        server.serve(port, None, out_folder)
Esempio n. 11
0
    def _execute(self, options, args):
        """Start the watcher."""
        try:
            from livereload import Server
        except ImportError:
            req_missing(['livereload'], 'use the "auto" command')
            return

        # Run an initial build so we are up-to-date
        subprocess.call(("nikola", "build"))

        port = options and options.get('port')

        server = Server()
        server.watch('conf.py', 'nikola build')
        server.watch('themes/', 'nikola build')
        server.watch('templates/', 'nikola build')
        server.watch(self.site.config['GALLERY_PATH'], 'nikola build')
        for item in self.site.config['post_pages']:
            server.watch(os.path.dirname(item[0]), 'nikola build')
        for item in self.site.config['FILES_FOLDERS']:
            server.watch(item, 'nikola build')

        out_folder = self.site.config['OUTPUT_FOLDER']
        if options and options.get('browser'):
            browser = True
        else:
            browser = False

            server.serve(port, None, out_folder, True, browser)
Esempio n. 12
0
def watch():
    server = Server()

    server.watch('templates/**/*', scan_files)
    server.watch('raml/*', scan_files)
    server.watch('examples/*.json', scan_files)
    server.serve()
Esempio n. 13
0
def livereload():
    db.create_all()
    server = Server(app)
    server.watch("gather/*.py")
    server.watch("gather/templates/*.html")
    server.watch("gather/assets/stylesheets/*.sass")
    server.watch("gather/assets/javascripts/*.coffee")
    server.serve(port=8000)
Esempio n. 14
0
def serve():
    from livereload import Server
    from livereload.watcher import Watcher
    watcher = Watcher()
    watcher.watch('site', ignore=lambda p: p.endswith('.babel'))
    watcher.watch('templates')
    server = Server(app, watcher)
    server.serve(port=8000)
Esempio n. 15
0
def main():
    server = Server()
    server.watch('assets/scripts', shell('make assets'))
    server.watch('assets/images', shell('make assets'))
    server.watch('assets/styles', shell('make styles'))
    server.watch('src', shell('make html'))

    server.serve(root='build/', port=8080)
Esempio n. 16
0
def serve():
    from livereload import Server
    from livereload.watcher import Watcher
    watcher = Watcher()
    watcher.watch('site')
    watcher.watch('templates')
    server = Server(app, watcher)
    server.serve(port=8000)
Esempio n. 17
0
 def start_livereload(self):
     from livereload import Server
     server = Server()
     for path in settings.STATICFILES_DIRS:
         server.watch(path)
     for path in settings.TEMPLATE_DIRS:
         server.watch(path)
     server.serve(port=settings.LIVERELOAD_PORT)
Esempio n. 18
0
def main(filenames, port, host, settings, debug, profile, profile_dir,
         profile_restriction):
    """Start fava for FILENAMES on http://host:port."""

    if profile_dir:
        profile = True
    if profile:
        debug = True

    env_filename = os.environ.get('BEANCOUNT_FILE', None)
    if env_filename:
        filenames = filenames + (env_filename,)

    if not filenames:
        raise click.UsageError('No file specified')

    app.config['BEANCOUNT_FILES'] = filenames
    app.config['USER_SETTINGS'] = settings

    load_settings()
    load_file()

    if debug:
        if profile:
            from werkzeug.contrib.profiler import ProfilerMiddleware
            app.config['PROFILE'] = True
            app.wsgi_app = ProfilerMiddleware(
                app.wsgi_app,
                restrictions=(profile_restriction,),
                profile_dir=profile_dir if profile_dir else None)

        app.run(host, port, debug)
    else:
        server = Server(app.wsgi_app)
        if settings:
            server.watch(settings, load_settings)

        def reload_source_files(api):
            filename = api.options['filename']
            api.load_file()
            include_path = os.path.dirname(filename)
            for filename in api.options['include'] + \
                    api.options['documents']:
                server.watch(os.path.join(include_path, filename),
                             lambda: reload_source_files(api))

        for api in app.config['APIS'].values():
            reload_source_files(api)

        try:
            server.serve(port=port, host=host, debug=debug)
        except OSError as error:
            if error.errno == errno.EADDRINUSE:
                print("Error: Can not start webserver because the port/address"
                      "is already in use.")
                print("Please choose another port with the '-p' option.")
            else:
                raise
Esempio n. 19
0
def serve():
    """Serve site at http://localhost:8000/"""
    rebuild()
    server = Server()
    server.watch('content/*/*.md', build_html)
    server.watch('theme/templates/*.html', build_html)
    server.watch('theme/scss/*.scss', build_css)
    server.watch('theme/scss/base/*.scss', build_css)
    server.serve(root='output', port=8000, host='localhost', open_url_delay=0.1)
Esempio n. 20
0
def livereload():
    from livereload import Server
    server = Server(app)

    # watch all js files else we'll only reload when app.js changes
    paths = pathlib.Path('bauble/static/').glob('**/*.js')
    for f in filter(lambda p: 'vendor' not in p, map(str, paths)):
        server.watch(f)
    server.serve(port=app.config.get('PORT', 5000))
Esempio n. 21
0
def watch(name):
    build(name)

    def _build():
        build(name)

    server = Server()
    server.watch(name, _build)
    server.serve(root='_build')
Esempio n. 22
0
def serve_docs():
    from livereload import Server, shell

    build_command = "sphinx-build -b html docs dist/docs"
    run(build_command)

    server = Server()
    server.watch("*.rst", shell(build_command))
    server.watch("docs/", shell(build_command))
    server.serve(root="dist/docs")
Esempio n. 23
0
 def run_livereload(self):
     app = create_app(root_path=self.folder, config_file=self.config_file)
     configure_views(app, self.file_renderer)
     server = Server(app)
     for glob_pattern in self.manager.globs_to_watch():
         server.watch('assets/%s' % glob_pattern,
             self.manager.build_environment)
     server.watch('templates/*', self.manager.build_environment)
     server.watch('templates/**/*', self.manager.build_environment)
     server.serve(host="0.0.0.0")
Esempio n. 24
0
def server(sitename):
    server = Server()
    server.watch(os.path.join('sites', sitename, 'content'), shell('python sitegen.py compile '+sitename))
    server.watch(os.path.join('sites', sitename, 'media'), shell('python sitegen.py collectmedia '+sitename))
    server.watch(os.path.join('sites', sitename, 'static', 'javascript'), shell('python sitegen.py generatestatic '+sitename))
    server.watch(os.path.join('sites', sitename, 'static', 'styles'), shell('python sitegen.py generatestatic '+sitename))
    server.watch(os.path.join('sites', sitename, 'templates'), shell('python sitegen.py compile '+sitename+' --force'))
    server.watch(os.path.join('static'), shell('python sitegen.py generatestatic '+sitename))
    server.watch(os.path.join('templates'), shell('python sitegen.py compile '+sitename+' --force'))
    server.serve(root=os.path.join('generated', sitename),port=8000, host='localhost')
Esempio n. 25
0
def serve():
    server = Server()

    load_data()

    server.watch('*.scss', css())
    server.watch('*.js', js())
    server.watch('*.html', render())

    server.serve(root='dist/', port=PORT, debug=False)
Esempio n. 26
0
def main():

    build_project_path = '_build'
    if not os.path.exists(build_project_path):
        os.system('make html')

    server = Server()
    server.watch('./*.rst', shell('make html'))
    server.watch('./*/*.rst', shell('make html'))
    webbrowser.open_new_tab('http://127.0.0.1:5500')
    server.serve(root='_build/html')
Esempio n. 27
0
def keep_alive(app, build_func):
    """Run the server and keep it reload and rebuild when contents changed
    :return:
    """
    live_server = Server(app.wsgi_app)

    # [live_server.watch(path.join(app.path, p), build_func) for p in
    # ['pages', 'static', 'templates', '_assets.yml', '_config.yml']]

    live_server.watch(app.path)
    live_server.serve()
Esempio n. 28
0
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)
Esempio n. 29
0
def server(host=None, port=5000, debug=True, live=False):
    """Run the app server."""
    from website.app import init_app
    app = init_app(set_backends=True, routes=True, mfr=True)

    if live:
        from livereload import Server
        server = Server(app.wsgi_app)
        server.watch(os.path.join(HERE, 'website', 'static', 'public'))
        server.serve(port=port)
    else:
        app.run(host=host, port=port, debug=debug, extra_files=[settings.ASSET_HASH_PATH])
Esempio n. 30
0
def develop_watch(options):
    server = Server()
    reloader = shell('pkill -HUP gunicorn')

    def js_bundle_changed():
        copy_js_bundle(options)

    server.watch('/mnt/src/front_demo/dist/main.js', js_bundle_changed)
    server.watch('/mnt/src/clang_ast_webservice/*.py', reloader)
    server.watch('/mnt/src/clang_ast_webservice/assets/*', reloader)
    server.serve()
    sys.exit(1)
Esempio n. 31
0
from livereload import Server, shell


server = Server()
server.serve(root='plotted_solid.html')
Esempio n. 32
0
def dev():
    from livereload import Server
    live_server = Server(app.wsgi_app)
    live_server.watch("**/*.*")
    live_server.serve(open_url=True)
Esempio n. 33
0
    structlog.configure(processors=[
        structlog.processors.StackInfoRenderer(),
        structlog.twisted.JSONRenderer()
    ],
                        context_class=dict,
                        logger_factory=twisted.LoggerFactory(),
                        wrapper_class=twisted.BoundLogger,
                        cache_logger_on_first_use=True)


if __name__ == "__main__":
    args = docopt(__doc__, version="LinkLib Livereload 0.1")
    db.init(app)
    init_logging()
    init_blueprints([index, link, login_view, register, api, testpage])
    init_login(app)
    if args['live']:
        app.debug = True
        server = Server(app.wsgi_app)
        server.watch('static/*')
        server.watch('templates/*')
        server.serve(liveport=8082,
                     host='localhost',
                     open_url_delay=0,
                     debug=True)
    elif args['waitress']:
        serve(app, listen='*:8080')
    else:
        print("init container.py")
        container.run(app, ENDPOINT, DEBUG)
Esempio n. 34
0
if __name__ == '__main__':
    try:
        opts, args = getopt.getopt(sys.argv[1:], "h:s:i",
                                   ["help", "es-server=", "use-voice-insight"])
    except getopt.GetoptError:
        _usage()
        sys.exit(2)
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            _usage()
            sys.exit()
        if opt in ('-s', '--es-server'):
            settings.es_server = arg
        if opt in ('-i', '--voice-insight'):
            print("Activating VoiceInsight")
            settings.vi = VoiceInsights()

    log_file = f"alexa.log"
    print(f"Logging to {log_file} (append)")
    logging.basicConfig(
        format='%(asctime)s %(levelname)s %(name)s %(message)s',
        filename=log_file,
        filemode='a',
        level=logging.INFO)
    print(f"Connecting to elasticsearch server on {settings.es_server}")
    connections.create_connection(hosts=[settings.es_server])
    print(f"Now listening for Alexa requests on port #: {port}")
    server = Server(app.wsgi_app)
    server.serve(host='0.0.0.0', port=port)
Esempio n. 35
0
    def build_docs(self,
                   path=None,
                   fmt='html',
                   outdir=None,
                   auto_open=True,
                   serve=True,
                   http=None,
                   archive=False,
                   upload=False):
        try:
            which.which('jsdoc')
        except which.WhichError:
            return die('jsdoc not found - please install from npm.')

        self.activate_pipenv(os.path.join(here, 'Pipfile'))

        import webbrowser
        from livereload import Server
        from moztreedocs.package import create_tarball

        outdir = outdir or os.path.join(self.topobjdir, 'docs')
        savedir = os.path.join(outdir, fmt)

        path = path or os.path.join(self.topsrcdir, 'tools')
        path = os.path.normpath(os.path.abspath(path))

        docdir = self._find_doc_dir(path)
        if not docdir:
            return die('failed to generate documentation:\n'
                       '%s: could not find docs at this location' % path)

        result = self._run_sphinx(docdir, savedir, fmt=fmt)
        if result != 0:
            return die('failed to generate documentation:\n'
                       '%s: sphinx return code %d' % (path, result))
        else:
            print('\nGenerated documentation:\n%s' % savedir)

        if archive:
            archive_path = os.path.join(outdir, '%s.tar.gz' % self.project)
            create_tarball(archive_path, savedir)
            print('Archived to %s' % archive_path)

        if upload:
            self._s3_upload(savedir, self.project, self.version)

        if not serve:
            index_path = os.path.join(savedir, 'index.html')
            if auto_open and os.path.isfile(index_path):
                webbrowser.open(index_path)
            return

        # Create livereload server. Any files modified in the specified docdir
        # will cause a re-build and refresh of the browser (if open).
        try:
            host, port = http.split(':', 1)
            port = int(port)
        except ValueError:
            return die('invalid address: %s' % http)

        server = Server()

        sphinx_trees = self.manager.trees or {savedir: docdir}
        for dest, src in sphinx_trees.items():
            run_sphinx = partial(self._run_sphinx, src, savedir, fmt=fmt)
            server.watch(src, run_sphinx)
        server.serve(host=host,
                     port=port,
                     root=savedir,
                     open_url_delay=0.1 if auto_open else None)
Esempio n. 36
0
    else:
        return "没有此权限!"


api = Api(app)
from common.common_cuid import select, update, delete, insert


class CUIDList(Resource):
    def get(self):
        return select(request.values)

    def post(self):
        return insert(request.values)

    def put(self):
        return update(request.values)

    def delete(self):
        return delete(request.values)


api.add_resource(CUIDList, '/CUID')
if __name__ == '__main__':
    from livereload import Server

    server = Server(app.wsgi_app)
    server.watch('**/*.*')
    server.serve()
    # app.run()
Esempio n. 37
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from os import path
import subprocess
from livereload import Server, shell

docsdir = path.dirname(path.abspath(__file__))
builddir = path.join(docsdir, '_build')

subprocess.run(['make', 'clean'])
subprocess.run(['make', 'html'])
cmd = shell([
    'sphinx-build', '-b', 'html', '-E', '-d',
    path.join(builddir, 'doctrees'), docsdir,
    path.join(builddir, 'html')
])

server = Server()
server.watch('*.py', cmd)
server.watch('../*.py', cmd)
server.watch('*.md', cmd)
server.watch('../*.md', cmd)
server.watch('_static/*.css', cmd)
server.watch('_templates/*.html', cmd)

server.serve(port=8889, root='_build/html', debug=True, restart_delay=1)
Esempio n. 38
0
#!/usr/bin/env python
from livereload import Server, shell

server = Server()
server.watch('content', shell('lightning -o www'))
server.serve(root='www')
Esempio n. 39
0
def live():
    server = Server()
    server.watch('en', shell('paver build_html', cwd='.'))
    server.serve(root='_build/html', open_url_delay=True)
Esempio n. 40
0
#!/usr/bin/env python

from livereload import Server, shell

server = Server()
server.watch('style.less', shell('lessc style.less', output='style.css'))
server.serve(open_url=True)
Esempio n. 41
0
    for chunk_number, library_piece in enumerate(library_chunked, start=1):
        rendered_page = template.render(
            library=library_piece,
            current_page_number=chunk_number,
            number_of_pages=number_of_pages,
        )

        with open(f"pages/index{chunk_number}.html", "w",
                  encoding="utf-8") as file:
            file.write(rendered_page)


if __name__ == "__main__":
    env = Environment(loader=FileSystemLoader("."),
                      autoescape=select_autoescape(
                          enabled_extensions=("html", ),
                          default_for_string=True,
                          default=True,
                      ))

    os.makedirs("media/books/", exist_ok=True)
    os.makedirs("media/images/", exist_ok=True)

    template = env.get_template("template.html")
    rebuild(template)

    server = Server()
    server.watch("template.html", rebuild)

    server.serve(root='.', default_filename="pages/index1.html")
Esempio n. 42
0
import os
from livereload import Server


if __name__ == '__main__':
    server = Server()
    server.serve(root='/site/')
Esempio n. 43
0
from livereload import Server, shell

server = Server()

server.watch("docs/*.rst", shell("make docs"))
server.serve(root="public/")
Esempio n. 44
0
def server():
    # watches for changes in sass
    # Creates server at port 8080
    server = Server()
    server.watch('./style/sass/style.scss', compile_sass)
    server.serve(port=8081, host='localhost')
Esempio n. 45
0
from connexion.resolver import RestyResolver
import connexion
from livereload import Server
from injector import Binder
from flask_injector import FlaskInjector
from services.provider import ItemsProvider


def configure(binder: Binder) -> Binder:
    binder.bind(ItemsProvider, ItemsProvider([{"Name": "Test 1"}]))

    return binder


if __name__ == '__main__':
    app = connexion.App(__name__, specification_dir='swagger/')
    app.add_api('my_super_app.yaml', resolver=RestyResolver('api'))
    FlaskInjector(app=app.app, modules=[configure])
    app.debug = True
    server = Server(app)
    server.watch('api/*.py')
    server.watch('swagger/*.yaml')
    server.serve(port=9090, host='0.0.0.0')
Esempio n. 46
0
def dev():
    live_server = Server(app.wsgi_app)
    live_server.watch('**/*.*')
    live_server.serve(open_url=False)
Esempio n. 47
0
#! /usr/bin/env python

# See http://mbless.de/blog/2015/04/22/livereload-to-please-the-web-developer.html
# to learn about the purpose of this file.

import os

ospj = os.path.join
from livereload import Server, shell


def ignore(filePath):
    keep = True
    if keep and filePath.startswith('../_make'):
        keep = False
    return not keep


server = Server()
server.watch('..', func=shell('make html'), delay=None, ignore=ignore)
cwd = os.getcwd()
webroot = ospj(cwd, 'build')
print 'webroot: ', webroot
server.serve(root=webroot)
Esempio n. 48
0
from livereload import Server, shell

server = Server()

# output stdout into a file
shcmd = shell('transcrypt -e 6 -n main.py', )
server.watch('views/*.py', shcmd)
server.watch('*.py', shcmd)

server.watch('wrap.js', shell('browserify -n -o bundle.js wrap.js'))

server.serve(root='.')
Esempio n. 49
0
#!/usr/bin/env python
"""
This module is designed to used with _livereload to 
make it a little easier to write Sphinx documentation.
Simply run the command::
    python sphinx_server.py

and browse to http://localhost:5500

livereload_: https://pypi.python.org/pypi/livereload
"""

from livereload import Server, shell

server = Server()
server.watch('*.rst', shell('make html', cwd='.'))
#server.watch('examples/*.rst', shell('make html', cwd='.'))
server.watch('conf.py', shell('make html', cwd='.'))
server.serve(root='_build/html')
#!/usr/bin/env python
from livereload import Server, shell
server = Server()
server.watch('index.html', 'elements/routing.html')
server.serve(port=8080, host='localhost')
Esempio n. 51
0
def dev():
    from livereload import Server
    live_server = Server(app.wsgi_app)
    live_server.watch('**/*.*')
    live_server.serve(open_url=False)
Esempio n. 52
0
def dev():
    """开发者用于实时监控代码,在网页端同步更新,提高开发效率"""
    from livereload import Server  # 导入监控包
    live_server = Server(app.wsgi_app)
    live_server.watch('**/*.*')  # 可用正则表达式,此处用于监测整个项目文件,
    live_server.serve(open_url=True)  # True表示自己打开浏览器
Esempio n. 53
0
livereload_: https://pypi.python.org/pypi/livereload
"""
import os

from livereload import Server, shell

rebuild_cmd = shell('make html', cwd='.')
rebuild_root = "_build/html"

watch_dirs = [
    '.',
    'release_notes',
]

watch_globs = ['*.rst', '*.ipynb']

watch_source_dir = "../smqtk_core"

server = Server()
server.watch('conf.py', rebuild_cmd)
# Cover above configured watch dirs and globs matrix.
for d in watch_dirs:
    for g in watch_globs:
        server.watch(os.path.join(d, g), rebuild_cmd)
# Watch source python files.
for dirpath, dirnames, filenames in os.walk(watch_source_dir):
    server.watch(os.path.join(dirpath, '*.py'), rebuild_cmd)
# Optionally change to host="0.0.0.0" to make available outside localhost.
server.serve(root=rebuild_root)
Esempio n. 54
0
def dev():
    from livereload import Server
    live_server = Server(app.wsgi_app)
    live_server.watch('**/*.*')  # 指明一个需要监测的目录,表示监测所有目录
    #自己打开浏览器
    live_server.serve(open_url=True)
Esempio n. 55
0
import application

from livereload import Server

app = application.app
app.debug = True
server = Server(app.wsgi_app)

server.watch('application.py')
server.watch('static/dist')
server.watch('templates')
server.serve(host='localhost')
Esempio n. 56
0
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fargovr.settings")

    from django.core.management import execute_from_command_line

    if 'livereload' in sys.argv:
        from django.core.wsgi import get_wsgi_application
        from livereload import Server
        application = get_wsgi_application()
        server = Server(application)

        # Add your watch
        # server.watch('path/to/file', 'your command')
        server.serve('8000')
    else:
        execute_from_command_line(sys.argv)
Esempio n. 57
0
from livereload import Server, shell

server = Server()

def alert():
    print('foo')
server.watch('./temp.py', alert)

# run a shell command
server.watch('./temp.py', shell('python3 ./temp.py', output='aa.log'))

server.serve(debug=True)
Esempio n. 58
0
        loaded = json.load(j)

    with open(CSS_FILE, "r") as c:
        css = c.read()

    env = Environment(loader=FileSystemLoader("."))
    env.filters["simpledate"] = simpledate
    env.globals['now'] = datetime.utcnow
    template = env.get_template("template.html")

    compiled = template.render({"css": css, "resume": loaded})

    with open(OUTPUT_HTML, "w") as oh:
        oh.write(compiled)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Process some integers.')
    parser.add_argument('--watch', action='store_true')
    args = parser.parse_args()

    if args.watch:
        server = Server()
        server.watch(INPUT_JSON, generate)
        server.watch(TEMPLATE_FILE, generate)
        server.watch("style.css", generate)
        webbrowser.open_new_tab("http://localhost:5500/")
        server.serve(root='index.html', live_css=False)
    else:
        generate()
Esempio n. 59
0
def serve(filename, host="0.0.0.0"):
    server = Server(make_app(filename, css))
    server.watch(filename)
    server.serve(host=host)
Esempio n. 60
0
#!/usr/bin/env python

from livereload import Server, shell

server = Server()

style = ("style.scss", "style.css")
script = ("typing-test.js", "typing-test-compiled.js")

server.watch(style[0], shell(["sass", style[0]], output=style[1]))
server.watch(script[0], shell(["babel", script[0]], output=script[1]))
server.watch("index.html")

server.serve(port=8080, host="localhost", open_url=True)