Hello world/Web server: Difference between revisions

Added Lua example
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(Added Lua example)
Line 1,132:
The task becomes simply ..
<lang lb>print "hello world!" </lang>
 
=={{header|Lua}}==
{{works with|lua|5.2.4}}
{{libheader|LuaSocket}}
<lang lua>local socket = request "socket"
local headers = "HTTP/1.1 200 OK\r\nCOntent-Type: text/html; charset=UTF-8\r\nContent-Length: %d\r\n\r\n%s"
local content = "<!doctype html><html><title>Hello, world!</title><h1>Hello, world!"
local server = assert(socket.bind("localhost", 8080))
repeat
local client = server:accept()
local ok = client:send(string.format(headers, #content, content))
client:close()
until not client or not ok
server:close()</lang>
 
=={{header|Mathematica}}==
6

edits