def serve(
    files,
    immutable,
    host,
    port,
    debug,
    reload,
    cors,
    sqlite_extensions,
    inspect_file,
    metadata,
    template_dir,
    plugins_dir,
    static,
    memory,
    config,
    version_note,
    help_config,
):
    """Serve up specified SQLite database files with a web UI"""
    if help_config:
        formatter = formatting.HelpFormatter()
        with formatter.section("Config options"):
            formatter.write_dl([
                (option.name, '{} (default={})'.format(
                    option.help, option.default
                ))
                for option in CONFIG_OPTIONS
            ])
        click.echo(formatter.getvalue())
        sys.exit(0)
    if reload:
        import hupper

        reloader = hupper.start_reloader("datasette.cli.serve")
        reloader.watch_files(files)
        if metadata:
            reloader.watch_files([metadata.name])

    inspect_data = None
    if inspect_file:
        inspect_data = json.load(open(inspect_file))

    metadata_data = None
    if metadata:
        metadata_data = json.loads(metadata.read())

    click.echo("Serve! files={} (immutables={}) on port {}".format(files, immutable, port))
    ds = Datasette(
        files,
        immutables=immutable,
        cache_headers=not debug and not reload,
        cors=cors,
        inspect_data=inspect_data,
        metadata=metadata_data,
        sqlite_extensions=sqlite_extensions,
        template_dir=template_dir,
        plugins_dir=plugins_dir,
        static_mounts=static,
        config=dict(config),
        memory=memory,
        version_note=version_note,
    )
    # Force initial hashing/table counting
    ds.inspect()
    ds.app().run(host=host, port=port, debug=debug)
def serve ( files , immutable , host , port , debug , reload , cors , sqlite_extensions , inspect_file , metadata , template_dir , plugins_dir , static , memory , config , version_note , help_config , ) : if help_config : formatter = formatting . HelpFormatter ( ) with formatter . section ( "Config options" ) : formatter . write_dl ( [ ( option . name , '{} (default={})' . format ( option . help , option . default ) ) for option in CONFIG_OPTIONS ] ) click . echo ( formatter . getvalue ( ) ) sys . exit ( 0 ) if reload : import hupper reloader = hupper . start_reloader ( "datasette.cli.serve" ) reloader . watch_files ( files ) if metadata : reloader . watch_files ( [ metadata . name ] ) inspect_data = None if inspect_file : inspect_data = json . load ( open ( inspect_file ) ) metadata_data = None if metadata : metadata_data = json . loads ( metadata . read ( ) ) click . echo ( "Serve! files={} (immutables={}) on port {}" . format ( files , immutable , port ) ) ds = Datasette ( files , immutables = immutable , cache_headers = not debug and not reload , cors = cors , inspect_data = inspect_data , metadata = metadata_data , sqlite_extensions = sqlite_extensions , template_dir = template_dir , plugins_dir = plugins_dir , static_mounts = static , config = dict ( config ) , memory = memory , version_note = version_note , ) ds . inspect ( ) ds . app ( ) . run ( host = host , port = port , debug = debug )
Serve up specified SQLite database files with a web UI