diff --git a/static/app.coffee b/static/app.coffee new file mode 100644 index 0000000..84a646c --- /dev/null +++ b/static/app.coffee @@ -0,0 +1,12 @@ +window.addEventListener "DOMContentLoaded", (event) -> + window.socket = new WebSocket(location.origin.replace(/^http/, "ws") + "/api") + counter = document.getElementById "counter" + + socket.addEventListener "message", (event) -> + if event.data == "err" + alert "error occured" + else + counter.innerText = event.data + +increment = -> socket.send("inc") +decrement = -> socket.send("dec") diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..64747b8 --- /dev/null +++ b/static/index.html @@ -0,0 +1,13 @@ + + + + IncDec + + + + + + +

loading

+ +