The browser is the new GUI !



Task

Serve our standard text   Goodbye, World!   to   http://localhost:8080/   so that it can be viewed with a web browser.

The provided solution must start or implement a server that accepts multiple client connections and serves text as requested.

Note that starting a web browser or opening a new window with this URL
is not part of the task.

Additionally, it is permissible to serve the provided page as a plain text file (there is no requirement to serve properly formatted HTML here).

The browser will generally do the right thing with simple text like this.




 
// Hello world! mode Server
 
#include <hopper.h>
main:
   fd=0,fdc=0,message=""
 
   {"HTTP/1.1 200 OK\n","Content-Type: text/html; charset=UTF-8\n\n"}cat
   {"<!DOCTYPE html><html><head><title>Bye-bye baby bye-bye</title>"},cat
   {"<style>body { background-color: #111 },cat
   {"h1 { font-size:4cm; text-align: center; color: black; text-shadow: 0 0 2mm red}</style>"}cat
   {"</head><body><h1>Goodbye, world!</h1></body></html>\n"}cat,
   mov(message)
 
/* Open socket in localhost (by default) */
/* Accept 5 conections (there are also 5 by default, if you put "any weá" there) */
   {5,8080}socket (OPENTCPSRV), mov(fd)
 
/* accept conection & send message */
   accept(fd), mov(fdc)
   {message},send(fdc)
 
/* close all */
   {fdc}socket(CLOSESOCK)
   {fd}socket(CLOSESOCK)
 
exit(0)
 