radical-api/api.py
Riley Housden 88ffd71911
Add gitea router
- added a gitea router
  - /gitea/latest endpoint gives the latest release version of a repo.
2021-12-02 05:21:39 -05:00

32 lines
No EOL
710 B
Python

import importlib
import logging
from pathlib import Path
from fastapi import FastAPI
logger = logging.getLogger("api")
api = FastAPI()
api_data = {"version": "2021.12.1.5", "author": "Riley Housden"}
def load_module(name: str):
module = importlib.import_module(name)
api.include_router(module.router)
logger.info(f"Loaded module: {module.__name__}")
for m_path in Path("routers").glob("*"):
if "__pycache__" in m_path.parts or "__init__" == m_path.stem:
continue
load_module(str(m_path).replace("/", ".").replace(".py", ""))
@api.get("/")
def quack():
return api_data
if __name__ == "__main__":
import uvicorn
api_data["version"] += "-dev"
uvicorn.run(api)