main
py 35 lines 785 Bytes
Raw
1 from helpers.api import ApiHandler, Request, Response
2 from helpers import cache
3
4
5 class CacheReset(ApiHandler):
6 @classmethod
7 def requires_auth(cls) -> bool:
8 return False
9
10 @classmethod
11 def requires_csrf(cls) -> bool:
12 return False
13
14 @classmethod
15 def requires_api_key(cls) -> bool:
16 return False
17
18 @classmethod
19 def requires_loopback(cls) -> bool:
20 return True
21
22 @classmethod
23 def get_methods(cls) -> list[str]:
24 return ["GET", "POST"]
25
26 async def process(self, input: dict, request: Request) -> dict | Response:
27 areas = input.get("areas", [])
28
29 if not areas:
30 cache.clear_all()
31 else:
32 for area in areas:
33 cache.clear(area)
34
35 return {"ok": True}