diff --git a/frontend.html b/frontend.html
index 9bac032..dcc7eaf 100644
--- a/frontend.html
+++ b/frontend.html
@@ -13,30 +13,44 @@
diff --git a/main.py b/main.py
index a54a241..8fb0032 100644
--- a/main.py
+++ b/main.py
@@ -110,16 +110,20 @@ async def root():
@app.get("/random")
async def get_random_file():
- """Get a random file hash from the mapping"""
+ """Get random file hashes from the mapping"""
if not indexer.file_mapping:
raise HTTPException(status_code=404, detail="No files indexed")
- random_hash = random.choice(list(indexer.file_mapping.keys()))
- return {"img": random_hash}
+ keys = list(indexer.file_mapping.keys())
+ random_idx = random.randint(0, len(keys) - 1)
+ current = keys[random_idx]
+ next_hash = keys[(random_idx + 1) % len(keys)]
+ prev_hash = keys[random_idx - 1] if random_idx > 0 else keys[-1]
+ return {"img": current, "next": next_hash, "previous": prev_hash}
-@app.get("/{file_hash}")
-async def get_file_by_hash(file_hash: str):
+@app.get("/{file_hash}/data")
+async def get_file_data(file_hash: str):
"""Serve a specific file by its hash"""
if file_hash not in indexer.file_mapping:
raise HTTPException(status_code=404, detail="File not found")
@@ -138,6 +142,19 @@ async def get_file_by_hash(file_hash: str):
)
+@app.get("/{file_hash}")
+async def get_file_info(file_hash: str):
+ """Get file info by hash"""
+ if file_hash not in indexer.file_mapping:
+ raise HTTPException(status_code=404, detail="File not found")
+
+ keys = list(indexer.file_mapping.keys())
+ idx = keys.index(file_hash)
+ next_hash = keys[(idx + 1) % len(keys)]
+ prev_hash = keys[idx - 1] if idx > 0 else keys[-1]
+ return {"img": file_hash, "next": next_hash, "previous": prev_hash}
+
+
# Optional: Add a health check endpoint
@app.get("/health")
async def health_check():