changes include: allow GET endpoints, redirect to codey.lol instead of returning status 422, clean junk from ai endpoint, add misc endpoint, add methods to lyric_search_new.sources.cache, other misc/cleanup
This commit is contained in:
22
base.py
22
base.py
@ -4,7 +4,7 @@ import importlib
|
||||
import logging
|
||||
import asyncio
|
||||
from typing import Any
|
||||
from fastapi import FastAPI
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from lyric_search_new.sources import redis_cache
|
||||
|
||||
@ -34,7 +34,7 @@ origins = [
|
||||
app.add_middleware(CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["POST"],
|
||||
allow_methods=["POST", "GET", "HEAD"],
|
||||
allow_headers=["*"])
|
||||
|
||||
|
||||
@ -49,9 +49,18 @@ Blacklisted routes
|
||||
def disallow_get():
|
||||
return util.get_blocked_response()
|
||||
|
||||
@app.get("/{any:path}")
|
||||
def disallow_get_any(var: Any = None): # pylint: disable=unused-argument
|
||||
return util.get_blocked_response()
|
||||
@app.get("/{path}")
|
||||
def disallow_get_any(request: Request, var: Any = None): # pylint: disable=unused-argument
|
||||
path = request.path_params['path']
|
||||
if not (
|
||||
isinstance(path, str)
|
||||
and
|
||||
path.split("/", maxsplit=1) == "widget"
|
||||
):
|
||||
return util.get_blocked_response()
|
||||
else:
|
||||
logging.info("OK, %s",
|
||||
path)
|
||||
|
||||
@app.post("/")
|
||||
def disallow_base_post():
|
||||
@ -79,9 +88,10 @@ lastfm_endpoints = importlib.import_module("endpoints.lastfm").LastFM(app, util,
|
||||
yt_endpoints = importlib.import_module("endpoints.yt").YT(app, util, constants, glob_state)
|
||||
# Below: XC endpoint(s)
|
||||
xc_endpoints = importlib.import_module("endpoints.xc").XC(app, util, constants, glob_state)
|
||||
|
||||
# Below: Karma endpoint(s)
|
||||
karma_endpoints = importlib.import_module("endpoints.karma").Karma(app, util, constants, glob_state)
|
||||
# Below: Misc endpoints
|
||||
misc_endpoints = importlib.import_module("endpoints.misc").Misc(app, util, constants, glob_state)
|
||||
|
||||
"""
|
||||
End Actionable Routes
|
||||
|
Reference in New Issue
Block a user