mirror of
https://github.com/linuxserver/docker-lsio-api.git
synced 2026-01-30 05:11:43 +08:00
26 lines
788 B
Python
26 lines
788 B
Python
from fastapi import FastAPI, HTTPException
|
|
from fastapi.responses import JSONResponse
|
|
from keyvaluestore import KeyValueStore
|
|
from models import ImagesResponse
|
|
import json
|
|
import traceback
|
|
|
|
api = FastAPI(docs_url="/", title="LinuxServer API", redoc_url=None, version="1.0")
|
|
|
|
@api.get("/health", summary="Get the health status")
|
|
async def health():
|
|
return "Success"
|
|
|
|
@api.get("/api/v1/images", response_model=ImagesResponse, summary="Get a list of images")
|
|
async def images():
|
|
try:
|
|
with KeyValueStore() as kv:
|
|
content = json.loads(kv["images"])
|
|
return JSONResponse(content=content)
|
|
except Exception:
|
|
print(traceback.format_exc())
|
|
raise HTTPException(status_code=404, detail="Not found")
|
|
|
|
if __name__ == "__main__":
|
|
api.run()
|