cleanup, linting
This commit is contained in:
parent
0d48b754de
commit
e434512fd0
@ -33,8 +33,8 @@ class RandMsg(FastAPI):
|
|||||||
"lib",
|
"lib",
|
||||||
"singerdbs",
|
"singerdbs",
|
||||||
"qajoke.db") # For qajoke db
|
"qajoke.db") # For qajoke db
|
||||||
db_query = "SELECT id, ('<b>Q:</b> ' || question || '<br/><b>A:</b> '" \
|
db_query = "SELECT id, ('<b>Q:</b> ' || question || '<br/><b>A:</b> ' \
|
||||||
"|| answer) FROM jokes ORDER BY RANDOM() LIMIT 1" # For qajoke db
|
|| answer) FROM jokes ORDER BY RANDOM() LIMIT 1" # For qajoke db
|
||||||
title_attr = "QA Joke DB"
|
title_attr = "QA Joke DB"
|
||||||
case 1:
|
case 1:
|
||||||
randmsg_db_path = os.path.join("/",
|
randmsg_db_path = os.path.join("/",
|
||||||
@ -42,8 +42,8 @@ class RandMsg(FastAPI):
|
|||||||
"lib",
|
"lib",
|
||||||
"singerdbs",
|
"singerdbs",
|
||||||
"randmsg.db") # For randmsg db
|
"randmsg.db") # For randmsg db
|
||||||
db_query = "SELECT id, msg FROM msgs WHERE" \
|
db_query = "SELECT id, msg FROM msgs WHERE \
|
||||||
"LENGTH(msg) <= 180 ORDER BY RANDOM() LIMIT 1" # For randmsg db
|
LENGTH(msg) <= 180 ORDER BY RANDOM() LIMIT 1" # For randmsg db
|
||||||
title_attr = "Random Msg DB"
|
title_attr = "Random Msg DB"
|
||||||
case 2:
|
case 2:
|
||||||
randmsg_db_path = os.path.join("/",
|
randmsg_db_path = os.path.join("/",
|
||||||
@ -51,8 +51,8 @@ class RandMsg(FastAPI):
|
|||||||
"lib",
|
"lib",
|
||||||
"singerdbs",
|
"singerdbs",
|
||||||
"trump.db") # For Trump Tweet DB
|
"trump.db") # For Trump Tweet DB
|
||||||
db_query = "SELECT id, content FROM tweets" \
|
db_query = "SELECT id, content FROM tweets \
|
||||||
"ORDER BY RANDOM() LIMIT 1" # For Trump Tweet DB
|
ORDER BY RANDOM() LIMIT 1" # For Trump Tweet DB
|
||||||
title_attr = "Trump Tweet DB"
|
title_attr = "Trump Tweet DB"
|
||||||
case 3:
|
case 3:
|
||||||
randmsg_db_path = os.path.join("/",
|
randmsg_db_path = os.path.join("/",
|
||||||
@ -60,8 +60,8 @@ class RandMsg(FastAPI):
|
|||||||
"lib",
|
"lib",
|
||||||
"singerdbs",
|
"singerdbs",
|
||||||
"philo.db") # For Philo DB
|
"philo.db") # For Philo DB
|
||||||
db_query = "SELECT id, (content || '<br> - ' || speaker) FROM quotes" \
|
db_query = "SELECT id, (content || '<br> - ' || speaker) FROM quotes \
|
||||||
"ORDER BY RANDOM() LIMIT 1" # For Philo DB
|
ORDER BY RANDOM() LIMIT 1" # For Philo DB
|
||||||
title_attr = "Philosophical Quotes DB"
|
title_attr = "Philosophical Quotes DB"
|
||||||
case 4:
|
case 4:
|
||||||
randmsg_db_path = os.path.join("/",
|
randmsg_db_path = os.path.join("/",
|
||||||
@ -69,8 +69,8 @@ class RandMsg(FastAPI):
|
|||||||
"lib",
|
"lib",
|
||||||
"singerdbs",
|
"singerdbs",
|
||||||
"hate.db") # For Hate DB
|
"hate.db") # For Hate DB
|
||||||
db_query = """SELECT id, ("<font color='#FF0000'>" || comment) FROM hate_speech" \
|
db_query = """SELECT id, ("<font color='#FF0000'>" || comment) FROM hate_speech \
|
||||||
"WHERE length(comment) <= 180 ORDER BY RANDOM() LIMIT 1"""
|
WHERE length(comment) <= 180 ORDER BY RANDOM() LIMIT 1"""
|
||||||
title_attr = "Hate Speech DB"
|
title_attr = "Hate Speech DB"
|
||||||
case 5:
|
case 5:
|
||||||
randmsg_db_path = os.path.join("/",
|
randmsg_db_path = os.path.join("/",
|
||||||
@ -78,8 +78,8 @@ class RandMsg(FastAPI):
|
|||||||
"lib",
|
"lib",
|
||||||
"singerdbs",
|
"singerdbs",
|
||||||
"rjokes.db") # r/jokes DB
|
"rjokes.db") # r/jokes DB
|
||||||
db_query = """SELECT id, (title || "<br>" || body) FROM jokes""" \
|
db_query = """SELECT id, (title || "<br>" || body) FROM jokes \
|
||||||
"""WHERE score >= 10000 ORDER BY RANDOM() LIMIT 1"""
|
WHERE score >= 10000 ORDER BY RANDOM() LIMIT 1"""
|
||||||
title_attr = "r/jokes DB"
|
title_attr = "r/jokes DB"
|
||||||
case 6:
|
case 6:
|
||||||
randmsg_db_path = os.path.join("/",
|
randmsg_db_path = os.path.join("/",
|
||||||
|
10
main.py
10
main.py
@ -3,8 +3,8 @@
|
|||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from typing import Union, Any
|
from typing import Any
|
||||||
from fastapi import FastAPI, HTTPException, Response, Form
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
@ -33,12 +33,8 @@ Blacklisted routes
|
|||||||
def disallow_get():
|
def disallow_get():
|
||||||
return util.get_blocked_response()
|
return util.get_blocked_response()
|
||||||
|
|
||||||
@app.get("/favicon.ico")
|
|
||||||
def disallow_get():
|
|
||||||
return util.get_blocked_response()
|
|
||||||
|
|
||||||
@app.get("/{any}")
|
@app.get("/{any}")
|
||||||
def disallow_get(any: Any):
|
def disallow_get_any(var: Any):
|
||||||
return util.get_blocked_response()
|
return util.get_blocked_response()
|
||||||
|
|
||||||
@app.post("/")
|
@app.post("/")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user