61 lines
1.1 KiB
Python
61 lines
1.1 KiB
Python
#!/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)
|
|
lyric_search_endpoint = importlib.import_module("endpoints.lyric_search").LyricSearch(app, util, constants)
|
|
|
|
|
|
|
|
"""
|
|
End Actionable Routes
|
|
""" |