From 56502d046c2ba3e4badecdcf3f05a43c2daa331f Mon Sep 17 00:00:00 2001 From: Tyler Hwang Date: Tue, 30 Jun 2026 20:44:17 -0700 Subject: [PATCH 01/10] Add pastes table --- modules/sqlite_helpers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/sqlite_helpers.py b/modules/sqlite_helpers.py index 62a3b6f..3be6906 100644 --- a/modules/sqlite_helpers.py +++ b/modules/sqlite_helpers.py @@ -13,6 +13,15 @@ def maybe_create_table(sqlite_file: str) -> bool: db = sqlite3.connect(sqlite_file) cursor = db.cursor() +#new paste table +cursor.execute(""" + CREATE TABLE IF NOT EXISTS pastes ( + alias TEXT PRIMARY KEY, + title TEXT, + content TEXT NOT NULL + ) +""") + try: create_table_query = """ CREATE TABLE IF NOT EXISTS urls ( From ed1f4b649c3b19cb52ca7df6678879eb54050e25 Mon Sep 17 00:00:00 2001 From: Tyler Hwang Date: Wed, 5 Aug 2026 18:45:13 -0700 Subject: [PATCH 02/10] Add paste API --- Dockerfile | 2 +- modules/sqlite_helpers.py | 39 +++++++++++++++++++++++++++++---------- pastes/1 | 1 + pastes/2 | 1 + server.py | 32 +++++++++++++++++++++++++++++++- 5 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 pastes/1 create mode 100644 pastes/2 diff --git a/Dockerfile b/Dockerfile index 70300bc..b0927cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9-slim-buster +FROM python:3.9-bullseye WORKDIR /app diff --git a/modules/sqlite_helpers.py b/modules/sqlite_helpers.py index 3be6906..7e24e5b 100644 --- a/modules/sqlite_helpers.py +++ b/modules/sqlite_helpers.py @@ -13,15 +13,6 @@ def maybe_create_table(sqlite_file: str) -> bool: db = sqlite3.connect(sqlite_file) cursor = db.cursor() -#new paste table -cursor.execute(""" - CREATE TABLE IF NOT EXISTS pastes ( - alias TEXT PRIMARY KEY, - title TEXT, - content TEXT NOT NULL - ) -""") - try: create_table_query = """ CREATE TABLE IF NOT EXISTS urls ( @@ -44,9 +35,10 @@ def maybe_create_table(sqlite_file: str) -> bool: CREATE UNIQUE INDEX IF NOT EXISTS idx_urls_alias ON urls (alias); """ - cursor.execute(create_pastes_table_query) cursor.execute(create_table_query) cursor.execute(create_index_query) + cursor.execute(create_pastes_table_query) + db.commit() return True except Exception: @@ -204,3 +196,30 @@ def increment_used_column(sqlite_file, alias: str, count=1): finally: cursor.close() db.close() +def insert_text_paste(sqlite_file: str) -> typing.Optional[int]: + db = sqlite3.connect(sqlite_file) + cursor = db.cursor() + try: + cursor.execute("INSERT INTO pastes DEFAULT VALUES") + db.commit() + return cursor.lastrowid + except Exception: + logger.exception("Inserting paste had an error") + return None + finally: + cursor.close() + db.close() + + +def paste_exists(sqlite_file: str, paste_id: int) -> bool: + db = sqlite3.connect(sqlite_file) + cursor = db.cursor() + try: + cursor.execute("SELECT id FROM pastes WHERE id = ?", (paste_id,)) + return cursor.fetchone() is not None + except Exception: + logger.exception("Getting paste had an error") + return False + finally: + cursor.close() + db.close() \ No newline at end of file diff --git a/pastes/1 b/pastes/1 new file mode 100644 index 0000000..95d09f2 --- /dev/null +++ b/pastes/1 @@ -0,0 +1 @@ +hello world \ No newline at end of file diff --git a/pastes/2 b/pastes/2 new file mode 100644 index 0000000..649297a --- /dev/null +++ b/pastes/2 @@ -0,0 +1 @@ +hello evan \ No newline at end of file diff --git a/server.py b/server.py index f56a5b1..d1b6e45 100644 --- a/server.py +++ b/server.py @@ -1,6 +1,6 @@ from typing import Optional +from fastapi.responses import RedirectResponse, HTMLResponse, FileResponse, PlainTextResponse from fastapi import FastAPI, Request, HTTPException, Response -from fastapi.responses import RedirectResponse, HTMLResponse, FileResponse from fastapi.middleware.cors import CORSMiddleware import logging import time @@ -18,6 +18,13 @@ from modules.cache import Cache from modules.qr_code import QRCode +from pathlib import Path +import os + +PASTES_DIR = Path("pastes") +PASTES_DIR.mkdir(exist_ok=True) + +MAX_PASTE_SIZE_BYTES = 10 * 1024 * 1024 app = FastAPI() args = get_args() @@ -155,6 +162,29 @@ async def delete_url(alias: str): return {"message": "URL deleted successfully"} else: raise HTTPException(status_code=HttpResponse.NOT_FOUND.code) +@app.post("/paste/create") +async def create_paste(request: Request): + body = await request.json() + text = body.get("text") + if text is None: + raise HTTPException(status_code=HttpResponse.BAD_REQUEST.code) + + paste_id = sqlite_helpers.insert_text_paste(DATABASE_FILE) + if paste_id is None: + raise HTTPException(status_code=500) + + paste_path = PASTES_DIR / str(paste_id) + paste_path.write_text(text, encoding="utf-8") + + return {"id": paste_id} + + +@app.get("/paste/view/{paste_id}") +async def view_paste(paste_id: int): + paste_path = PASTES_DIR / str(paste_id) + if not paste_path.exists(): + raise HTTPException(status_code=HttpResponse.NOT_FOUND.code) + return PlainTextResponse(paste_path.read_text(encoding="utf-8")) @app.get("/qr/{alias}") async def qr(alias: str): From 7cbdcc9f4f5fc74f4ef1413149d8d7ffb22d0d3d Mon Sep 17 00:00:00 2001 From: evan Date: Mon, 10 Aug 2026 08:43:20 -0700 Subject: [PATCH 03/10] rebase, ignore pastes/ --- .gitignore | 3 +++ Dockerfile | 2 +- pastes/1 | 1 - pastes/2 | 1 - pastes/keep | 0 5 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 pastes/1 delete mode 100644 pastes/2 create mode 100644 pastes/keep diff --git a/.gitignore b/.gitignore index 634f0f0..8686580 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +pastes/* +!pastes/keep diff --git a/Dockerfile b/Dockerfile index b0927cf..16fbe2c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9-bullseye +FROM python:3.10.2-slim-buster WORKDIR /app diff --git a/pastes/1 b/pastes/1 deleted file mode 100644 index 95d09f2..0000000 --- a/pastes/1 +++ /dev/null @@ -1 +0,0 @@ -hello world \ No newline at end of file diff --git a/pastes/2 b/pastes/2 deleted file mode 100644 index 649297a..0000000 --- a/pastes/2 +++ /dev/null @@ -1 +0,0 @@ -hello evan \ No newline at end of file diff --git a/pastes/keep b/pastes/keep new file mode 100644 index 0000000..e69de29 From c380e724609fbb3a5dccfbc054c784e473b0aa81 Mon Sep 17 00:00:00 2001 From: evan Date: Mon, 10 Aug 2026 08:44:19 -0700 Subject: [PATCH 04/10] keep docker base image as is --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 16fbe2c..70300bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10.2-slim-buster +FROM python:3.9-slim-buster WORKDIR /app From 4fe2265647ae5f1807b71f4abdc58d193e069b7c Mon Sep 17 00:00:00 2001 From: evan Date: Mon, 10 Aug 2026 09:21:35 -0700 Subject: [PATCH 05/10] correct json parsing, add HttpResponse.REQUEST_TOO_LARGE --- modules/constants.py | 8 ++++++ modules/sqlite_helpers.py | 14 +++++++--- server.py | 57 ++++++++++++++++++++++++++++++++------- 3 files changed, 65 insertions(+), 14 deletions(-) diff --git a/modules/constants.py b/modules/constants.py index f74225d..fee9a5c 100644 --- a/modules/constants.py +++ b/modules/constants.py @@ -8,12 +8,19 @@

Return to homepage

""" +REQUEST_TOO_LARGE_HTML = """ +

Request too large.

+ +

The bytes sent was size "{request_size}" which exceeds max size of {max_size}.

+""" + class HttpResponse(enum.Enum): OK = (200, "success") BAD_REQUEST = (400, "

No URL was found in your request

") NOT_FOUND = (404, NOT_FOUND_HTML) CONFLICT = (409, "

Alias already exists

") + REQUEST_TOO_LARGE = (413, REQUEST_TOO_LARGE_HTML) INVALID_ARGUMENT_EXCEPTION = (422, "

Alias is invalid

") INTERNAL_SERVER_ERROR = (500, "

Internal server error

") def __init__(self, code, content): @@ -25,6 +32,7 @@ def __init__(self, code, content): 400: HttpResponse.BAD_REQUEST, 404: HttpResponse.NOT_FOUND, 409: HttpResponse.CONFLICT, + 413: HttpResponse.REQUEST_TOO_LARGE, 422: HttpResponse.INVALID_ARGUMENT_EXCEPTION, 500: HttpResponse.INTERNAL_SERVER_ERROR, } diff --git a/modules/sqlite_helpers.py b/modules/sqlite_helpers.py index 7e24e5b..d8a0f7c 100644 --- a/modules/sqlite_helpers.py +++ b/modules/sqlite_helpers.py @@ -196,16 +196,22 @@ def increment_used_column(sqlite_file, alias: str, count=1): finally: cursor.close() db.close() -def insert_text_paste(sqlite_file: str) -> typing.Optional[int]: + +def insert_paste(sqlite_file: str, paste_id: str, title: str): db = sqlite3.connect(sqlite_file) cursor = db.cursor() + try: - cursor.execute("INSERT INTO pastes DEFAULT VALUES") + sql = "INSERT INTO pastes(paste_id, title) VALUES (?, ?)" + val = (paste_id, title) + cursor.execute(sql, val) db.commit() - return cursor.lastrowid + return True + except sqlite3.IntegrityError: + return False except Exception: logger.exception("Inserting paste had an error") - return None + return False finally: cursor.close() db.close() diff --git a/server.py b/server.py index d1b6e45..6f8fcf0 100644 --- a/server.py +++ b/server.py @@ -162,24 +162,49 @@ async def delete_url(alias: str): return {"message": "URL deleted successfully"} else: raise HTTPException(status_code=HttpResponse.NOT_FOUND.code) + @app.post("/paste/create") async def create_paste(request: Request): - body = await request.json() - text = body.get("text") - if text is None: - raise HTTPException(status_code=HttpResponse.BAD_REQUEST.code) + # 1. Enforce size limit (using UTF-8 byte length) + try: + payload = await request.json() + except Exception: + logging.exception("/paste/create couldnt parse json") + raise HTTPException( + status_code=HttpResponse.BAD_REQUEST.code, + detail="Invalid JSON payload" + ) + text_bytes = payload.get("text", "").encode("utf-8") + if len(text_bytes) > MAX_PASTE_SIZE_BYTES: + raise HTTPException( + status_code=HttpResponse.REQUEST_TOO_LARGE, + detail="Paste content exceeds the maximum allowed size of 10MB." + ) - paste_id = sqlite_helpers.insert_text_paste(DATABASE_FILE) - if paste_id is None: - raise HTTPException(status_code=500) + # 2. Generate unique alias based on content length (or hash) + paste_id = generate_alias(len(payload.text)) + # 3. Insert into SQLite database (including the title) + success = sqlite_helpers.insert_paste(DATABASE_FILE, paste_id, payload.title) + if not success: + raise HTTPException( + status_code=HttpResponse.INTERNAL_SERVER_ERROR, + detail="Failed to save paste metadata." + ) + + # 4. Write content to disk paste_path = PASTES_DIR / str(paste_id) - paste_path.write_text(text, encoding="utf-8") + paste_path.write_bytes(text_bytes) - return {"id": paste_id} + # 5. Return Pastebin-style response with URL + return { + "status": "success", + "id": paste_id, + "url": f"/paste/{paste_id}" + } -@app.get("/paste/view/{paste_id}") +@app.get("/paste/{paste_id}") async def view_paste(paste_id: int): paste_path = PASTES_DIR / str(paste_id) if not paste_path.exists(): @@ -217,6 +242,18 @@ async def http_exception_handler(request, exc): requested_url=str(original_url), base_url=str(base_url) ) + if status_code_enum == HttpResponse.REQUEST_TOO_LARGE: + request_size = "Unknown" + try: + body = await request.json() + if isinstance(body, dict) and "text" in body: + request_size = len(body["text"].encode("utf-8")) + except Exception: + pass + content = content.format( + request_size=request_size, + max_size=MAX_PASTE_SIZE_BYTES, + ) return HTMLResponse( content=content, status_code=status_code_enum.code ) From f8337c49f3dfe9130a50bdac85a3491ce4ab6bf5 Mon Sep 17 00:00:00 2001 From: evan Date: Mon, 10 Aug 2026 09:22:36 -0700 Subject: [PATCH 06/10] stray changes, ready to test --- modules/sqlite_helpers.py | 4 ++-- server.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/sqlite_helpers.py b/modules/sqlite_helpers.py index d8a0f7c..48eea0b 100644 --- a/modules/sqlite_helpers.py +++ b/modules/sqlite_helpers.py @@ -35,9 +35,9 @@ def maybe_create_table(sqlite_file: str) -> bool: CREATE UNIQUE INDEX IF NOT EXISTS idx_urls_alias ON urls (alias); """ + cursor.execute(create_pastes_table_query) cursor.execute(create_table_query) cursor.execute(create_index_query) - cursor.execute(create_pastes_table_query) db.commit() return True @@ -228,4 +228,4 @@ def paste_exists(sqlite_file: str, paste_id: int) -> bool: return False finally: cursor.close() - db.close() \ No newline at end of file + db.close() diff --git a/server.py b/server.py index 6f8fcf0..76b920d 100644 --- a/server.py +++ b/server.py @@ -1,6 +1,6 @@ from typing import Optional -from fastapi.responses import RedirectResponse, HTMLResponse, FileResponse, PlainTextResponse from fastapi import FastAPI, Request, HTTPException, Response +from fastapi.responses import RedirectResponse, HTMLResponse, FileResponse, PlainTextResponse from fastapi.middleware.cors import CORSMiddleware import logging import time From c8079fd947de99ad92c9085e27b7988967abf1b8 Mon Sep 17 00:00:00 2001 From: evan Date: Thu, 20 Aug 2026 09:52:20 -0700 Subject: [PATCH 07/10] add --paste-directory, CLEEZY_PASTE_API_KEY --- Dockerfile | 2 +- README.md | 40 ++++++++++++++++++++++----------------- docker-compose.dev.yml | 2 ++ docker-compose.yml | 4 ++++ modules/args.py | 5 +++++ modules/sqlite_helpers.py | 2 +- server.py | 27 +++++++++++++++----------- 7 files changed, 52 insertions(+), 30 deletions(-) diff --git a/Dockerfile b/Dockerfile index 70300bc..7866111 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9-slim-buster +FROM python:3.9-slim-bullseye WORKDIR /app diff --git a/README.md b/README.md index 170555d..be37285 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ sce run z ``` - [ ] ensure the server is running locally at `http://localhost:8000` +if youre running cleezy on sce.sjsu.edu, make an .env file like +``` +CLEEZY_PASTE_API_KEY=NOTHING_REALLY +``` + ## APIs ### To add URL send HTTP POST request to http://localhost:8000/create_url with body @@ -37,6 +42,24 @@ Open http://localhost:8000/list in the browser - send HTTP POST request to http://localhost:8000/delete/myurl - verify the url was deleted by opening http://localhost:8000/list in the browser +### To create a paste +if you didnt make an env file like above, no need to pass in api key +```sh +curl -X POST "http://localhost:8000/paste/create" \ + -H "Content-Type: application/json" \ + -H "X-API-Key: your_secret_key_here" \ + -d '{"title": "My First Paste", "text": "hello2"}' + +# example response is +# {"status":"success","id":"6556e","url":"/paste/6556e"} +``` + +### To view a paste +```sh +# put the paste id after the `/paste/` in the url, like below +curl http://localhost:8000/paste/6556e +``` + ## SQLite Migrations If you have an existing database and want to add a column, see below ```sh @@ -50,20 +73,3 @@ apt install -y sqlite3 ALTER TABLE urls ADD COLUMN expires_at DATETIME DEFAULT NULL; ``` -## QR Embeds -### tl;dr THEY DON'T WORK ON DISCORD - -here's the discord embed debugger that tries to scrape embed stuff from the url it is provided. 'internal error' means discord wasn't able to do this - -image - -here's some logs from cleezy-nginx after the embed debugger was run and a twitter post with the QR url was sent -``` -172.25.0.14 - - [01/Sep/2025:19:03:43 +0000] "GET /qr/EMBEDTEST1 HTTP/1.0" 404 185 "-" "Twitterbot/1.0" -172.25.0.14 - - [01/Sep/2025:19:03:43 +0000] "GET /qr/EMBEDTEST1 HTTP/1.0" 404 185 "-" "Twitterbot/1.0" -``` -as you can see, only twitter was able to connect to the site and scrape, display embed stuff - -image - -ATP, the source of the issue is not very apparent diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 0eca4bc..224caeb 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -12,6 +12,7 @@ services: - --qr-code-base-url=http://localhost:8000/find - --port=8000 - --qr-code-center-image-path=/app/assets/SCE_logo.png + - --paste-directory=/app/pastes - -vvv ports: - 8000:8000 @@ -20,6 +21,7 @@ services: - ./server.py:/app/server.py - ./modules:/app/modules - ./assets:/app/assets + - ./pastes:/app/pastes environment: - WATCHFILES_FORCE_POLLING=true diff --git a/docker-compose.yml b/docker-compose.yml index d347454..b1d868e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,12 +11,16 @@ services: - --qr-code-cache-state-file=/tmp/cleezy-state - --qr-code-base-url=https://sce.sjsu.edu/s - --qr-code-center-image-path=/app/assets/SCE_logo.png + - --paste-directory=/app/pastes - -vvv volumes: - cleezy_data:/tmp/ - ./server.py:/app/server.py - ./modules:/app/modules - ./assets:/app/assets + - ./pastes:/app/pastes + env_file: + - .env volumes: cleezy_data: diff --git a/modules/args.py b/modules/args.py index b2cf099..8ad36ab 100644 --- a/modules/args.py +++ b/modules/args.py @@ -68,4 +68,9 @@ def get_args(): default="America/Los_Angeles", help="the timezone that url expiration checks will use. defaults to America/Los_Angeles" ) + parser.add_argument( + "--paste-directory", + default="/app/pastes", + help="the timezone that url expiration checks will use. defaults to America/Los_Angeles" + ) return parser.parse_args() diff --git a/modules/sqlite_helpers.py b/modules/sqlite_helpers.py index 48eea0b..eae0829 100644 --- a/modules/sqlite_helpers.py +++ b/modules/sqlite_helpers.py @@ -202,7 +202,7 @@ def insert_paste(sqlite_file: str, paste_id: str, title: str): cursor = db.cursor() try: - sql = "INSERT INTO pastes(paste_id, title) VALUES (?, ?)" + sql = "INSERT INTO pastes(id, title) VALUES (?, ?)" val = (paste_id, title) cursor.execute(sql, val) db.commit() diff --git a/server.py b/server.py index 76b920d..22e1468 100644 --- a/server.py +++ b/server.py @@ -21,13 +21,16 @@ from pathlib import Path import os -PASTES_DIR = Path("pastes") -PASTES_DIR.mkdir(exist_ok=True) +CLEEZY_PASTE_API_KEY = os.getenv("CLEEZY_PASTE_API_KEY") MAX_PASTE_SIZE_BYTES = 10 * 1024 * 1024 app = FastAPI() args = get_args() + +PASTES_DIR = Path(args.paste_directory) +PASTES_DIR.mkdir(exist_ok=True) + alias_queue = Queue() app.add_middleware( @@ -165,7 +168,13 @@ async def delete_url(alias: str): @app.post("/paste/create") async def create_paste(request: Request): - # 1. Enforce size limit (using UTF-8 byte length) + api_key = request.headers.get("x-api-key") + + if CLEEZY_PASTE_API_KEY is None: + logging.warning("CLEEZY_PASTE_API_KEY isn't set, skipping api key check") + elif api_key != CLEEZY_PASTE_API_KEY: + raise HTTPException(status_code=401, detail=f"Invalid API Key '{api_key}'") + try: payload = await request.json() except Exception: @@ -181,22 +190,18 @@ async def create_paste(request: Request): detail="Paste content exceeds the maximum allowed size of 10MB." ) - # 2. Generate unique alias based on content length (or hash) - paste_id = generate_alias(len(payload.text)) + paste_id = generate_alias(len(payload.get('text'))) - # 3. Insert into SQLite database (including the title) - success = sqlite_helpers.insert_paste(DATABASE_FILE, paste_id, payload.title) + success = sqlite_helpers.insert_paste(DATABASE_FILE, paste_id, payload.get('title', 'Untitled Paste')) if not success: raise HTTPException( status_code=HttpResponse.INTERNAL_SERVER_ERROR, detail="Failed to save paste metadata." ) - # 4. Write content to disk paste_path = PASTES_DIR / str(paste_id) paste_path.write_bytes(text_bytes) - # 5. Return Pastebin-style response with URL return { "status": "success", "id": paste_id, @@ -205,8 +210,8 @@ async def create_paste(request: Request): @app.get("/paste/{paste_id}") -async def view_paste(paste_id: int): - paste_path = PASTES_DIR / str(paste_id) +async def view_paste(paste_id: str): + paste_path = PASTES_DIR / paste_id if not paste_path.exists(): raise HTTPException(status_code=HttpResponse.NOT_FOUND.code) return PlainTextResponse(paste_path.read_text(encoding="utf-8")) From 76834039a44092beed3db1daf39c217e74641ca6 Mon Sep 17 00:00:00 2001 From: evan Date: Thu, 20 Aug 2026 20:40:01 -0700 Subject: [PATCH 08/10] if exc.status_code not in http_code_to_enum: --- server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server.py b/server.py index 22e1468..8f6ea4d 100644 --- a/server.py +++ b/server.py @@ -238,6 +238,10 @@ async def qr(alias: str): @app.exception_handler(HTTPException) async def http_exception_handler(request, exc): + if exc.status_code not in http_code_to_enum: + return HTMLResponse( + status_code=exc.status_code + ) status_code_enum = http_code_to_enum[exc.status_code] content = status_code_enum.content if status_code_enum == HttpResponse.NOT_FOUND: From 7639b9d8f96f02ba76bce3730ad5ea169cf93454 Mon Sep 17 00:00:00 2001 From: evan Date: Thu, 20 Aug 2026 20:44:04 -0700 Subject: [PATCH 09/10] exc.detail --- server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 8f6ea4d..bd72314 100644 --- a/server.py +++ b/server.py @@ -240,7 +240,8 @@ async def qr(alias: str): async def http_exception_handler(request, exc): if exc.status_code not in http_code_to_enum: return HTMLResponse( - status_code=exc.status_code + status_code=exc.status_code, + content=exc.detail, ) status_code_enum = http_code_to_enum[exc.status_code] content = status_code_enum.content From b7c93ccceb51066361f2b1075915890f84a71688 Mon Sep 17 00:00:00 2001 From: evan Date: Thu, 20 Aug 2026 20:52:04 -0700 Subject: [PATCH 10/10] delete paste_exists --- modules/sqlite_helpers.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/modules/sqlite_helpers.py b/modules/sqlite_helpers.py index eae0829..45d0629 100644 --- a/modules/sqlite_helpers.py +++ b/modules/sqlite_helpers.py @@ -215,17 +215,3 @@ def insert_paste(sqlite_file: str, paste_id: str, title: str): finally: cursor.close() db.close() - - -def paste_exists(sqlite_file: str, paste_id: int) -> bool: - db = sqlite3.connect(sqlite_file) - cursor = db.cursor() - try: - cursor.execute("SELECT id FROM pastes WHERE id = ?", (paste_id,)) - return cursor.fetchone() is not None - except Exception: - logger.exception("Getting paste had an error") - return False - finally: - cursor.close() - db.close()