annotate website/src/examples/sse_push.html.luan @ 1833:e6a5f178e5f9 default tip

remove discord
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 22 Dec 2024 18:46:25 -0700
parents 3e9f26404433
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1738
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Io = require "luan:Io.luan"
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local Http = require "luan:http/Http.luan"
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 return function()
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local request = Http.request
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local message = request.parameters.message
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 if message ~= nil then
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local url = request.url()
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 Http.push(url,message)
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 end
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 Io.stdout = Http.response.text_writer()
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 %>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 <!doctype html>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 <html>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 <body>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 <h1>push server-sent events</h1>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 <form method=post>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 <p><textarea name=message></textarea></p>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 <p><input type=submit></p>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 </form>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 </body>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 </html>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 <%
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 end