Skip to content

Commit 3239a43

Browse files
style: reformatted datasette startup log message
1 parent e7a1a10 commit 3239a43

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

temoa_runner.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,21 +381,33 @@ async def websocket_endpoint(websocket: WebSocket):
381381
if __name__ == "__main__":
382382
import uvicorn
383383
import subprocess
384+
import os
384385

385386
ensure_assets()
386387

387388
# Start Datasette in a subprocess
388389
print("Starting Datasette on port 8001...", flush=True)
389390
try:
390391
log_file = open("datasette.log", "a")
391-
# Prepare list of things to serve: output directory and tutorial db
392-
to_serve = [str(Path("output").absolute())]
392+
393+
# Create output directory if missing
394+
output_base = Path("output")
395+
output_base.mkdir(exist_ok=True)
396+
393397
tutorial_db = Path("assets/tutorial_database.sqlite")
398+
399+
# Discover all sqlite files in the output directory recursively
400+
to_serve = [str(p.absolute()) for p in output_base.rglob("*.sqlite")]
394401
if tutorial_db.exists():
395402
to_serve.append(str(tutorial_db.absolute()))
396403

397-
# Use sys.executable -m datasette to ensure we run in the same environment
398-
# Only serve the results and tutorial data, NOT the whole root (prevents config.json errors)
404+
# Isolate Datasette from host configs (like ~/.datasette/config.json)
405+
# by pointing HOME to a known clean location.
406+
env = os.environ.copy()
407+
env["HOME"] = str(Path(".").absolute())
408+
409+
# Use sys.executable -m datasette to ensure we run in the same environment.
410+
# We serve ONLY the explicit database files found.
399411
subprocess.Popen(
400412
[
401413
sys.executable,
@@ -413,6 +425,7 @@ async def websocket_endpoint(websocket: WebSocket):
413425
],
414426
stdout=log_file,
415427
stderr=log_file,
428+
env=env,
416429
)
417430
print(
418431
"Datasette process launched. (Logs available in datasette.log)", flush=True

0 commit comments

Comments
 (0)