comparison website/src/examples/sse_push.html.luan @ 1738:9713f7fd50b3

server-sent events
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2022 19:23:53 -0600
parents
children 3e9f26404433
comparison
equal deleted inserted replaced
1737:6c9aea554691 1738:9713f7fd50b3
1 local Io = require "luan:Io.luan"
2 local Http = require "luan:http/Http.luan"
3 local Logging = require "luan:logging/Logging.luan"
4 local logger = Logging.logger "init"
5
6
7 return function()
8 local request = Http.request
9 local message = request.parameters.message
10 if message ~= nil then
11 local url = request.url()
12 Http.push(url,message)
13 end
14 Io.stdout = Http.response.text_writer()
15 %>
16 <!doctype html>
17 <html>
18 <body>
19 <h1>push server-sent events</h1>
20 <form method=post>
21 <p><textarea name=message></textarea></p>
22 <p><input type=submit></p>
23 </form>
24 </body>
25 </html>
26 <%
27 end