requests_async

This commit is contained in:
2025-01-24 19:26:07 -05:00
parent 06c2d48818
commit 0b47373127
8 changed files with 55 additions and 123 deletions

View File

@ -41,18 +41,15 @@ class RandMsg(FastAPI):
match db_rand_selected:
case 0:
randmsg_db_path = os.path.join("/",
"var",
"lib",
"singerdbs",
"qajoke.db") # For qajoke db
"usr", "local", "share",
"sqlite_dbs", "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
title_attr = "QA Joke DB"
case 1 | 9:
randmsg_db_path = os.path.join("/",
"var",
"lib",
"singerdbs",
"usr", "local", "share",
"sqlite_dbs",
"randmsg.db") # For randmsg db
db_query = "SELECT id, msg FROM msgs WHERE \
LENGTH(msg) <= 180 ORDER BY RANDOM() LIMIT 1" # For randmsg db
@ -61,45 +58,40 @@ class RandMsg(FastAPI):
title_attr = "Random Msg DB"
case 2:
randmsg_db_path = os.path.join("/",
"var",
"lib",
"singerdbs",
"usr", "local", "share",
"sqlite_dbs",
"trump.db") # 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("/",
"var",
"lib",
"singerdbs",
"usr", "local", "share",
"sqlite_dbs",
"philo.db") # 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("/",
"var",
"lib",
"singerdbs",
"usr", "local", "share",
"sqlite_dbs",
"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"""
title_attr = "Hate Speech DB"
case 5:
randmsg_db_path = os.path.join("/",
"var",
"lib",
"singerdbs",
"usr", "local", "share",
"sqlite_dbs",
"rjokes.db") # r/jokes DB
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("/",
"var",
"lib",
"singerdbs",
"usr", "local", "share",
"sqlite_dbs",
"donnies.db") # Donnies DB
random.seed()
twilight_or_mice = random.choice(["twilight", "mice"])