Resolves #15, addl unrelated changes
This commit is contained in:
13
base.py
13
base.py
@ -5,16 +5,22 @@ import logging
|
||||
|
||||
from typing import Any
|
||||
from fastapi import FastAPI
|
||||
from fastapi.security import APIKeyHeader, APIKeyQuery
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
app = FastAPI()
|
||||
util = importlib.import_module("util").Utilities()
|
||||
|
||||
constants = importlib.import_module("constants").Constants()
|
||||
util = importlib.import_module("util").Utilities(app, constants)
|
||||
glob_state = importlib.import_module("state").State(app, util, constants)
|
||||
|
||||
api_key_query = APIKeyQuery(name=constants.API_KEY_NAME, auto_error=False)
|
||||
api_key_header = APIKeyQuery(name=f"x-{constants.API_KEY_NAME}", auto_error=False)
|
||||
|
||||
|
||||
origins = [
|
||||
"https://codey.lol",
|
||||
]
|
||||
@ -26,8 +32,6 @@ allow_methods=["POST"],
|
||||
allow_headers=["*"])
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Blacklisted routes
|
||||
"""
|
||||
@ -37,7 +41,7 @@ def disallow_get():
|
||||
return util.get_blocked_response()
|
||||
|
||||
@app.get("/{any}")
|
||||
def disallow_get_any(var: Any):
|
||||
def disallow_get_any(var: Any = None):
|
||||
return util.get_blocked_response()
|
||||
|
||||
@app.post("/")
|
||||
@ -56,6 +60,7 @@ Actionable Routes
|
||||
counter_endpoints = importlib.import_module("endpoints.counters").Counters(app, util, constants, glob_state)
|
||||
randmsg_endpoint = importlib.import_module("endpoints.rand_msg").RandMsg(app, util, constants, glob_state)
|
||||
transcription_endpoints = importlib.import_module("endpoints.transcriptions").Transcriptions(app, util, constants, glob_state)
|
||||
ai_endpoints = importlib.import_module("endpoints.ai").AI(app, util, constants, glob_state)
|
||||
# Below also provides: /lyric_cache_list/ (in addition to /lyric_search/)
|
||||
lyric_search_endpoint = importlib.import_module("endpoints.lyric_search").LyricSearch(app, util, constants, glob_state)
|
||||
# Below provides numerous LastFM-fed endpoints
|
||||
|
Reference in New Issue
Block a user