rename main.py -> base.py
This commit is contained in:
66
base.py
Normal file
66
base.py
Normal file
@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3.12
|
||||
|
||||
import importlib
|
||||
import logging
|
||||
|
||||
from typing import Any
|
||||
from fastapi import FastAPI
|
||||
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}")
|
||||
def disallow_get_any(var: Any):
|
||||
return util.get_blocked_response()
|
||||
|
||||
@app.post("/")
|
||||
def disallow_base_post():
|
||||
return util.get_blocked_response()
|
||||
|
||||
|
||||
"""
|
||||
End Blacklisted Routes
|
||||
"""
|
||||
|
||||
|
||||
"""
|
||||
Actionable Routes
|
||||
"""
|
||||
|
||||
randmsg_endpoint = importlib.import_module("endpoints.rand_msg").RandMsg(app, util, constants)
|
||||
# Below also provides: /lyric_cache_list/ (in addition to /lyric_search/)
|
||||
lyric_search_endpoint = importlib.import_module("endpoints.lyric_search").LyricSearch(app, util, constants)
|
||||
# Below provides numerous LastFM-fed endpoints
|
||||
lastfm_endpoints = importlib.import_module("endpoints.lastfm").LastFM(app, util, constants)
|
||||
# Below: YT endpoint(s)
|
||||
yt_endpoints = importlib.import_module("endpoints.yt").YT(app, util, constants)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
End Actionable Routes
|
||||
"""
|
Reference in New Issue
Block a user