diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-02-21 13:57:25 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-02-21 13:57:25 +0000 |
commit | 7daf034fd94a8a07f9cbb5d070a085de69d184fd (patch) | |
tree | 22fd77042834975166ea7d75c20decb433ec6ea3 | |
parent | e995422137ad124718c97326e205ce531d8b0536 (diff) | |
download | netsurf-test-7daf034fd94a8a07f9cbb5d070a085de69d184fd.tar.gz netsurf-test-7daf034fd94a8a07f9cbb5d070a085de69d184fd.tar.bz2 |
Async delayed hello world, first draft
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r-- | cgi-bin/and-then-js-async-cb-adds-timeout.js | 11 | ||||
-rwxr-xr-x | cgi-bin/and-then-js.cgi | 24 | ||||
-rw-r--r-- | html/async-delayed-hello-world.html | 9 | ||||
-rw-r--r-- | html/hello-world.js | 3 |
4 files changed, 47 insertions, 0 deletions
diff --git a/cgi-bin/and-then-js-async-cb-adds-timeout.js b/cgi-bin/and-then-js-async-cb-adds-timeout.js new file mode 100644 index 0000000..b53678b --- /dev/null +++ b/cgi-bin/and-then-js-async-cb-adds-timeout.js @@ -0,0 +1,11 @@ +/* JS returned by and-then-js.cgi + * this is to be loaded as an async script + */ + +/* After one second */ +setTimeout(1000, function() { + /* Add a <script> tag */ + var script = document.createElement("SCRIPT"); + script.src = "https://test.netsurf-browser.org/hello-world.js"; + document.body.appendChild(script); +}); diff --git a/cgi-bin/and-then-js.cgi b/cgi-bin/and-then-js.cgi new file mode 100755 index 0000000..1930df3 --- /dev/null +++ b/cgi-bin/and-then-js.cgi @@ -0,0 +1,24 @@ +#!/usr/bin/python3 + +import cgi +import cgitb +import os +import time + +cgitb.enable() + +qs = cgi.parse_qs(os.getenv("QUERY_STRING", "t=1&val=async-cb-adds-timeout")) + +content = qs.get("val", ["async-cb-adds-timeout"])[0] + +print("Content-Type: text/javascript") +print("") + +sleep_time = int(qs.get("t", [1])[0]) + +print("{}Sleeping for {} seconds".format(prefix, sleep_time)) + +time.sleep(sleep_time) + +print("{}Done sleeping {} seconds".format(prefix,sleep_time)) + diff --git a/html/async-delayed-hello-world.html b/html/async-delayed-hello-world.html new file mode 100644 index 0000000..a2cbc20 --- /dev/null +++ b/html/async-delayed-hello-world.html @@ -0,0 +1,9 @@ +<html> + <head> + <title>Hello World</title> + <script src="https://test.netsurf-browser.org/cgi-bin/and-then-js.cgi?t=5&val=async-cb-adds-timeout"></script> + </head> + <body> + <h1>Check the console for a hello world log</h1> + </body> +</html> diff --git a/html/hello-world.js b/html/hello-world.js new file mode 100644 index 0000000..03a10db --- /dev/null +++ b/html/hello-world.js @@ -0,0 +1,3 @@ +/* Hello World */ + +console.log("Hello World") |