2024-08-10 22:49:00 -04:00
|
|
|
#!/usr/bin/env python3.12
|
|
|
|
|
|
|
|
import importlib
|
|
|
|
import logging
|
|
|
|
|
2024-08-11 13:55:11 -04:00
|
|
|
from typing import Any
|
|
|
|
from fastapi import FastAPI
|
2024-08-10 22:49:00 -04:00
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
origins = [
|
|
|
|
"https://codey.lol",
|
|
|
|
]
|
|
|
|
|
|
|
|
app.add_middleware(CORSMiddleware,
|
|
|
|
allow_origins=origins,
|
|
|
|
allow_credentials=True,
|
|
|
|
allow_methods=["POST"],
|
|
|
|
allow_headers=["*"])
|
|
|
|
|
|
|
|
"""
|
|
|
|
Blacklisted routes
|
|
|
|
"""
|
|
|
|
|
|
|
|
@app.get("/")
|
|
|
|
def disallow_get():
|
|
|
|
return util.get_blocked_response()
|
|
|
|
|
|
|
|
@app.get("/{any}")
|
2024-08-11 13:55:11 -04:00
|
|
|
def disallow_get_any(var: Any):
|
2024-08-10 22:49:00 -04:00
|
|
|
return util.get_blocked_response()
|
|
|
|
|
|
|
|
@app.post("/")
|
|
|
|
def disallow_base_post():
|
|
|
|
return util.get_blocked_response()
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
End Blacklisted Routes
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
Actionable Routes
|
|
|
|
"""
|
|
|
|
|
2024-08-11 13:49:07 -04:00
|
|
|
randmsg_endpoint = importlib.import_module("endpoints.rand_msg").RandMsg(app, util, constants)
|
2024-08-11 17:04:06 -04:00
|
|
|
# Below also provides: /lyric_cache_list/ (in addition to /lyric_search/)
|
2024-08-11 13:49:07 -04:00
|
|
|
lyric_search_endpoint = importlib.import_module("endpoints.lyric_search").LyricSearch(app, util, constants)
|
2024-08-11 17:28:43 -04:00
|
|
|
# Below provides numerous LastFM-fed endpoints
|
|
|
|
lastfm_endpoints = importlib.import_module("endpoints.lastfm").LastFM(app, util, constants)
|
2024-08-13 10:50:11 -04:00
|
|
|
# Below: YT endpoint(s)
|
|
|
|
yt_endpoints = importlib.import_module("endpoints.yt").YT(app, util, constants)
|
2024-08-13 17:49:51 -04:00
|
|
|
# Below: Transcription endpoints
|
|
|
|
transcription_endpoints = importlib.import_module("endpoints.transcriptions").Transcriptions(app, util, constants)
|
2024-08-10 22:49:00 -04:00
|
|
|
|
2024-08-11 12:46:24 -04:00
|
|
|
|
2024-08-10 22:49:00 -04:00
|
|
|
"""
|
|
|
|
End Actionable Routes
|
2024-08-11 07:14:08 -04:00
|
|
|
"""
|