From 6dcd46fee0eb43da1b35834af45afcf803624fa6 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Sun, 24 Mar 2024 21:49:05 +1100 Subject: [PATCH] Udpate default script to a random svg line graph generator --- app.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index a3d8c05..e38c477 100644 --- a/app.py +++ b/app.py @@ -41,16 +41,34 @@ API_URL = 'https://isolator.peterstockings.com/execute' #'http://127.0.0.1:5000/ DEFAULT_FUNCTION_NAME = 'foo' DEFAULT_SCRIPT = """async (req) => { - console.log(`Hello ${environment.name}`) - return HtmlResponse( - `
-

Method:${req.method}

-

Hello ${environment.name}

-
`) + console.log(`Method:${req.method}`) + console.log(`Generating ${environment.lines} random lines...`) + let svgContent = ""; + + for (let i = 0; i < environment.lines; i++) { + console.log(i) + let pathD = "M2 " + Math.random() * 79; + let circles = ""; + + for (let x = 12; x <= 202; x += 10) { + let y = Math.random() * 79 + pathD += ` L${x} ${y}`; + circles += ``; + } + + let pathColor = `rgb(${Math.random() * 255}, ${Math.random() * 255}, ${Math.random() * 255})`; + svgContent += ` + + + ${circles} + `; + } + + return HtmlResponse(`${svgContent}`); }""" DEFAULT_ENVIRONMENT = """{ - "name": "Peter" + "lines": 3 }""" def map_isolator_response_to_flask_response(response):