view 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
line wrap: on
line source

local Io = require "luan:Io.luan"
local Http = require "luan:http/Http.luan"
local Logging = require "luan:logging/Logging.luan"
local logger = Logging.logger "init"


return function()
	local request = Http.request
	local message = request.parameters.message
	if message ~= nil then
		local url = request.url()
		Http.push(url,message)
	end
	Io.stdout = Http.response.text_writer()
%>
<!doctype html>
<html>
	<body>
		<h1>push server-sent events</h1>
		<form method=post>
			<p><textarea name=message></textarea></p>
			<p><input type=submit></p>
		</form>
	</body>
</html>
<%
end