ford442 commited on
Commit
8555914
·
verified ·
1 Parent(s): f3a0a38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -35,7 +35,12 @@ STORAGE_MAP = {
35
  "sample": {"folder": "samples/", "index": "samples/_samples.json"},
36
  "music": {"folder": "music/", "index": "music/_music.json"},
37
  "note": {"folder": "notes/", "index": "notes/_notes.json"},
38
- "default": {"folder": "misc/", "index": "misc/_misc.json"}
 
 
 
 
 
39
  }
40
 
41
  # --- GLOBAL OBJECTS ---
@@ -1008,5 +1013,17 @@ async def sync_gcs_storage():
1008
  await cache.clear()
1009
  return report
1010
 
 
 
 
 
 
 
 
 
 
 
 
 
1011
  if __name__ == "__main__":
1012
  uvicorn.run(app, host="0.0.0.0", port=7860)
 
35
  "sample": {"folder": "samples/", "index": "samples/_samples.json"},
36
  "music": {"folder": "music/", "index": "music/_music.json"},
37
  "note": {"folder": "notes/", "index": "notes/_notes.json"},
38
+ "default": {"folder": "misc/", "index": "misc/_misc.json"},
39
+ "shaders": {
40
+ "bucket": "your-gcs-bucket",
41
+ "prefix": "shaders/",
42
+ "allowed_ext": [".wgsl", ".json"]
43
+ }
44
  }
45
 
46
  # --- GLOBAL OBJECTS ---
 
1013
  await cache.clear()
1014
  return report
1015
 
1016
+ @app.post("/api/shaders/{shader_id}/rate")
1017
+ async def rate_shader(shader_id: str, rating: float): # 1.0–5.0
1018
+ meta = load_metadata(shader_id)
1019
+ meta["stars"] = (meta["stars"] * meta["rating_count"] + rating) / (meta["rating_count"] + 1)
1020
+ meta["rating_count"] += 1
1021
+ save_metadata(shader_id, meta)
1022
+ return meta
1023
+
1024
+ @app.get("/api/shaders")
1025
+ async def list_shaders(category: str = None, min_stars: float = 0):
1026
+ # return sorted list with description + avg stars
1027
+
1028
  if __name__ == "__main__":
1029
  uvicorn.run(app, host="0.0.0.0", port=7860)