[+] Progress report webhook
This commit is contained in:
+10
-2
@@ -18,6 +18,10 @@ log = logging.getLogger("rich")
|
|||||||
app = fastapi.FastAPI()
|
app = fastapi.FastAPI()
|
||||||
|
|
||||||
|
|
||||||
|
def say(msg: str):
|
||||||
|
os.system(f"say '{msg}'")
|
||||||
|
|
||||||
|
|
||||||
# Create a webhook endpoint
|
# Create a webhook endpoint
|
||||||
@app.post('/webhook')
|
@app.post('/webhook')
|
||||||
async def webhook(request: fastapi.Request):
|
async def webhook(request: fastapi.Request):
|
||||||
@@ -27,9 +31,13 @@ async def webhook(request: fastapi.Request):
|
|||||||
|
|
||||||
# Get the JSON body
|
# Get the JSON body
|
||||||
obj = await request.json()
|
obj = await request.json()
|
||||||
if obj.get('Progress') == 100:
|
prog = obj.get('Progress')
|
||||||
|
if prog == 100:
|
||||||
# Make a noise
|
# Make a noise
|
||||||
os.system("say 'Meow Meow Meow! Print Complete, Print Complete, Meow Meow Meow Meow Meow!'")
|
say('Meow Meow Meow! Print Complete, Print Complete, Meow Meow Meow Meow Meow!')
|
||||||
|
|
||||||
|
elif obj.get("EventType") == 6:
|
||||||
|
say(f"{obj.get('PrinterName')} Progress: {prog}%")
|
||||||
|
|
||||||
log.info(obj)
|
log.info(obj)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user