70 lines
1.2 KiB
Python
70 lines
1.2 KiB
Python
|
#!/usr/bin/env python3.12
|
||
|
|
||
|
import importlib
|
||
|
import logging
|
||
|
|
||
|
from typing import Union, Any
|
||
|
from fastapi import FastAPI, HTTPException, Response, Form
|
||
|
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("/favicon.ico")
|
||
|
def disallow_get():
|
||
|
return util.get_blocked_response()
|
||
|
|
||
|
@app.get("/{any}")
|
||
|
def disallow_get(any: Any):
|
||
|
return util.get_blocked_response()
|
||
|
|
||
|
@app.post("/")
|
||
|
def disallow_base_post():
|
||
|
return util.get_blocked_response()
|
||
|
|
||
|
|
||
|
"""
|
||
|
End Blacklisted Routes
|
||
|
"""
|
||
|
|
||
|
|
||
|
"""
|
||
|
Actionable Routes
|
||
|
"""
|
||
|
|
||
|
lyric_search_endpoint = importlib.import_module("endpoints.LyricSearch").LyricSearch(app, util, constants)
|
||
|
|
||
|
|
||
|
"""
|
||
|
End Actionable Routes
|
||
|
"""
|
||
|
|
||
|
|
||
|
|
||
|
# @app.get("/items/{item_id}")
|
||
|
# def read_item(item_id: int, q: Union[str, None] = None):
|
||
|
# return {"item_id": item_id, "q": q}
|