bucket-testing / app.py
malteos
mount public (4)
5dee603 unverified
raw
history blame contribute delete
694 Bytes
from fastapi import FastAPI
import os
import duckdb
data_dir = "./data"
db_path = data_dir + "/db/cc_explorer.db"
print("db_path", db_path)
app = FastAPI()
@app.get("/")
def greet_json():
con = duckdb.connect()
con.execute("INSTALL sqlite; LOAD sqlite;")
try:
row = con.execute("""
SELECT crawl_id
FROM sqlite_scan(?, 'crawls')
ORDER BY crawl_date DESC
LIMIT 1
""", [db_path]).fetchone()
latest_crawl_id = row[0]
except Exception:
latest_crawl_id = "n/a"
return {"Hello": "World!", "latest_crawl": latest_crawl_id, "exists": os.path.exists(db_path), "data_ls": os.listdir(data_dir)}