Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
kw['monitor_factory'] = lambda cb: PollingFileMonitor(cb, **pkw)
if opts.watchdog:
from hupper.watchdog import WatchdogFileMonitor
kw['monitor_factory'] = WatchdogFileMonitor
if opts.watchman:
from hupper.watchman import WatchmanFileMonitor
kw['monitor_factory'] = WatchmanFileMonitor
if opts.reload_interval:
kw['reload_interval'] = opts.reload_interval
hupper.start_reloader(__name__ + '.main', **kw)
if hupper.is_active():
hupper.get_reloader().watch_files([os.path.join(here, 'foo.ini')])
hupper.get_reloader().watch_files(opts.watch_files)
if opts.callback_file:
with open(opts.callback_file, 'ab') as fp:
fp.write('{:d}\n'.format(int(time.time())).encode('utf8'))
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
"""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(
def serve(dbs, host, port, debug, reload, cache, max_workers, parse_module):
if reload:
import hupper
hupper.start_reloader('csvapi.cli.serve')
app.config.DB_ROOT_DIR = dbs
app.config.CSV_CACHE_ENABLED = cache
app.config.MAX_WORKERS = max_workers
app.config.RESPONSE_TIMEOUT = RESPONSE_TIMEOUT
app.config.PARSE_MODULE = parse_module
app.run(host=host, port=port, debug=debug)