Hello world/Web server: Difference between revisions

Content added Content deleted
(Add NetRexx implementation)
Line 412: Line 412:
This is difficult, although possible, in Liberty BASIC, but it's close relative Run BASIC is designed for serving webpages easily. The task becomes simply ..
This is difficult, although possible, in Liberty BASIC, but it's close relative Run BASIC is designed for serving webpages easily. The task becomes simply ..
<lang lb>print "hello world!" </lang>
<lang lb>print "hello world!" </lang>

=={{header|NetRexx}}==
{{Trans|Java}}
<lang NetRexx>/* NetRexx */
options replace format comments java crossref symbols binary

class RHelloWorldWebServer public

properties public constant
isTrue = boolean (1 == 1)
isFalse = boolean (1 \== 1)
greeting1 = "Goodbye, World!"
greeting2 = '' -
|| 'HTTP/1.1 200 OK\r\n' -
|| 'Content-Type: text/html; charset=UTF-8\r\n\r\n' -
|| '<?xml version="1.0" encoding="UTF-8"?>\r\n' -
|| '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n' -
|| '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\r\n' -
|| '<header>\r\n' -
|| '<title>Hello</title>\r\n' -
|| '<style type="text/css">body {font-family: sans-serif;}</style>\r\n' -
|| '</header>\r\n' -
|| '<body>\r\n' -
|| '<h2 style="text-align: center;">' || greeting1 || '</h2>\r\n' -
|| '</body>\r\n' -
|| '</html>\r\n' -
|| ''

properties static inheritable
terminate = isFalse -- TODO: provide a less draconian means to terminate the listener loop

method main(args = String[]) public static signals IOException
listener = ServerSocket(8080)
loop label listener forever
if terminate then leave listener
sock = listener.accept()
PrintWriter(sock.getOutputStream(), isTrue).println(greeting2)
sock.close()
end listener
return
</lang>


=={{header|Objeck}}==
=={{header|Objeck}}==