diff --git a/server.py b/server.py index a12cc14..c7fec00 100644 --- a/server.py +++ b/server.py @@ -1,3 +1,4 @@ +import contextlib import io import json import os @@ -124,7 +125,7 @@ CACHE_FILE = CACHE_DIR / "db.sqlite3" logging.debug("Cache file: %r", CACHE_FILE) -@app.on_event("startup") +@contextlib.asynccontextmanager async def startup(): if not CACHE_DIR.exists(): CACHE_DIR.mkdir(parents=True) @@ -139,6 +140,7 @@ async def startup(): ) """ ) + yield def upload_media(domain: str, access_token: str, file: io.BytesIO, filename: str, content_type: str): @@ -196,7 +198,7 @@ def preview_url( cursor = conn.cursor() cursor.execute( "SELECT metadata,ts FROM cache WHERE url = ?", - (url, ts) + (url,) ) results = cursor.fetchall() if results: