From e434512fd00fa79b00d86a69db7f2a4a486f8523 Mon Sep 17 00:00:00 2001 From: codey Date: Sun, 11 Aug 2024 13:55:11 -0400 Subject: [PATCH] cleanup, linting --- endpoints/rand_msg.py | 24 ++++++++++++------------ main.py | 10 +++------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/endpoints/rand_msg.py b/endpoints/rand_msg.py index 3e423ac..6868483 100644 --- a/endpoints/rand_msg.py +++ b/endpoints/rand_msg.py @@ -33,8 +33,8 @@ class RandMsg(FastAPI): "lib", "singerdbs", "qajoke.db") # For qajoke db - db_query = "SELECT id, ('Q: ' || question || '
A: '" \ - "|| answer) FROM jokes ORDER BY RANDOM() LIMIT 1" # For qajoke db + db_query = "SELECT id, ('Q: ' || question || '
A: ' \ + || answer) FROM jokes ORDER BY RANDOM() LIMIT 1" # For qajoke db title_attr = "QA Joke DB" case 1: randmsg_db_path = os.path.join("/", @@ -42,8 +42,8 @@ class RandMsg(FastAPI): "lib", "singerdbs", "randmsg.db") # For randmsg db - db_query = "SELECT id, msg FROM msgs WHERE" \ - "LENGTH(msg) <= 180 ORDER BY RANDOM() LIMIT 1" # For randmsg db + db_query = "SELECT id, msg FROM msgs WHERE \ + LENGTH(msg) <= 180 ORDER BY RANDOM() LIMIT 1" # For randmsg db title_attr = "Random Msg DB" case 2: randmsg_db_path = os.path.join("/", @@ -51,8 +51,8 @@ class RandMsg(FastAPI): "lib", "singerdbs", "trump.db") # For Trump Tweet DB - db_query = "SELECT id, content FROM tweets" \ - "ORDER BY RANDOM() LIMIT 1" # For Trump Tweet DB + db_query = "SELECT id, content FROM tweets \ + ORDER BY RANDOM() LIMIT 1" # For Trump Tweet DB title_attr = "Trump Tweet DB" case 3: randmsg_db_path = os.path.join("/", @@ -60,8 +60,8 @@ class RandMsg(FastAPI): "lib", "singerdbs", "philo.db") # For Philo DB - db_query = "SELECT id, (content || '
- ' || speaker) FROM quotes" \ - "ORDER BY RANDOM() LIMIT 1" # For Philo DB + db_query = "SELECT id, (content || '
- ' || speaker) FROM quotes \ + ORDER BY RANDOM() LIMIT 1" # For Philo DB title_attr = "Philosophical Quotes DB" case 4: randmsg_db_path = os.path.join("/", @@ -69,8 +69,8 @@ class RandMsg(FastAPI): "lib", "singerdbs", "hate.db") # For Hate DB - db_query = """SELECT id, ("" || comment) FROM hate_speech" \ - "WHERE length(comment) <= 180 ORDER BY RANDOM() LIMIT 1""" + db_query = """SELECT id, ("" || comment) FROM hate_speech \ + WHERE length(comment) <= 180 ORDER BY RANDOM() LIMIT 1""" title_attr = "Hate Speech DB" case 5: randmsg_db_path = os.path.join("/", @@ -78,8 +78,8 @@ class RandMsg(FastAPI): "lib", "singerdbs", "rjokes.db") # r/jokes DB - db_query = """SELECT id, (title || "
" || body) FROM jokes""" \ - """WHERE score >= 10000 ORDER BY RANDOM() LIMIT 1""" + db_query = """SELECT id, (title || "
" || body) FROM jokes \ + WHERE score >= 10000 ORDER BY RANDOM() LIMIT 1""" title_attr = "r/jokes DB" case 6: randmsg_db_path = os.path.join("/", diff --git a/main.py b/main.py index b1d680d..aff1fee 100644 --- a/main.py +++ b/main.py @@ -3,8 +3,8 @@ import importlib import logging -from typing import Union, Any -from fastapi import FastAPI, HTTPException, Response, Form +from typing import Any +from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware logger = logging.getLogger() @@ -33,12 +33,8 @@ Blacklisted routes def disallow_get(): return util.get_blocked_response() -@app.get("/favicon.ico") -def disallow_get(): - return util.get_blocked_response() - @app.get("/{any}") -def disallow_get(any: Any): +def disallow_get_any(var: Any): return util.get_blocked_response() @app.post("/")