support-ticker/app/main.py

42 lines
884 B
Python

import secrets
from fastapi import FastAPI, HTTPException, Security
from fastapi.openapi.models import APIKey
####################
# - Utilities
####################
async def g_api_key(
api_key_header: APIKey = Security(api_key_header),
) -> APIKey:
if api_key_header and secrets.compare_digest(
str(api_key_header),
settings.api_key.get_secret_value(),
):
return api_key_header
raise HTTPException(
status_code=HTTP_403_FORBIDDEN,
detail="Wrong API key.",
)
####################
# - Types
####################
class PInstSupCategory(Enum)
####################
# - FastAPI App
####################
app = FastAPI(
prefix="/v1",
dependencies=[Security(g_api_key)],
)
@app.post("/report/support")
async def report_support(
category:
description: str,
) -> bool:
"""Report an instance of granted Python Installation support."""
return await d_old_app_passes()