cleanup, linting

This commit is contained in:
codey 2024-08-11 13:55:11 -04:00
parent 0d48b754de
commit e434512fd0
2 changed files with 15 additions and 19 deletions

View File

@ -33,8 +33,8 @@ class RandMsg(FastAPI):
"lib",
"singerdbs",
"qajoke.db") # For qajoke db
db_query = "SELECT id, ('<b>Q:</b> ' || question || '<br/><b>A:</b> '" \
"|| answer) FROM jokes ORDER BY RANDOM() LIMIT 1" # For qajoke db
db_query = "SELECT id, ('<b>Q:</b> ' || question || '<br/><b>A:</b> ' \
|| 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 || '<br> - ' || speaker) FROM quotes" \
"ORDER BY RANDOM() LIMIT 1" # For Philo DB
db_query = "SELECT id, (content || '<br> - ' || 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, ("<font color='#FF0000'>" || comment) FROM hate_speech" \
"WHERE length(comment) <= 180 ORDER BY RANDOM() LIMIT 1"""
db_query = """SELECT id, ("<font color='#FF0000'>" || 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 || "<br>" || body) FROM jokes""" \
"""WHERE score >= 10000 ORDER BY RANDOM() LIMIT 1"""
db_query = """SELECT id, (title || "<br>" || body) FROM jokes \
WHERE score >= 10000 ORDER BY RANDOM() LIMIT 1"""
title_attr = "r/jokes DB"
case 6:
randmsg_db_path = os.path.join("/",

10
main.py
View File

@ -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("/")