-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcustom_routes.py
48 lines (37 loc) · 1.41 KB
/
custom_routes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import server
from . import persistence
from aiohttp import web
@server.PromptServer.instance.routes.get("/comfy-pets/user")
async def comfy_pets_get_user(request):
try:
data = persistence.get_current_user()
return web.json_response({
"user": data
}, content_type='application/json')
except Exception as e:
print("Error:", e)
return web.json_response({ "error": e }, status=400)
@server.PromptServer.instance.routes.post("/comfy-pets/balance")
async def comfy_pets_update_balance(request):
try:
data = await request.json()
balance = data.get("balance")
persistence.update_balance(balance)
return web.json_response({
"message": "Balance updated successfully"
}, content_type='application/json')
except Exception as e:
print("Error:", e)
return web.json_response({ "error": str(e) }, status=400)
@server.PromptServer.instance.routes.post("/comfy-pets/inventory")
async def comfy_pets_update_inventory(request):
try:
data = await request.json()
inventory = data.get("inventory")
persistence.update_inventory(inventory)
return web.json_response({
"message": "Inventory updated successfully"
}, content_type='application/json')
except Exception as e:
print("Error:", e)
return web.json_response({ "error": str(e) }, status=400)