Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
serv: httprun[8080; {"HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\nGoodbye, World!"}]
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
load["handlers.ant"]
|
||||
serv: httprun[8080; {httpwrap["Goodbye, World!"]}]
|
||||
|
|
@ -0,0 +1 @@
|
|||
kill[serv]
|
||||
13
Task/Hello-world-Web-server/FunL/hello-world-web-server.funl
Normal file
13
Task/Hello-world-Web-server/FunL/hello-world-web-server.funl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
native java.io.PrintWriter
|
||||
native java.net.ServerSocket
|
||||
|
||||
val port = 8080
|
||||
val listener = ServerSocket( port )
|
||||
|
||||
printf( 'Listening at port %1$d\n', port )
|
||||
|
||||
forever
|
||||
socket = listener.accept()
|
||||
PrintWriter( socket.getOutputStream(), true ).println( 'hello world' )
|
||||
socket.shutdownOutput()
|
||||
socket.close()
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
local(server) = net_tcp
|
||||
handle => { #server->close }
|
||||
#server->bind(8080) & listen & forEachAccept => {
|
||||
local(con) = #1
|
||||
|
||||
split_thread => {
|
||||
handle => { #con->close }
|
||||
local(request) = ''
|
||||
// Read in the request in chunks until you have it all
|
||||
{
|
||||
#request->append(#con->readSomeBytes(8096))
|
||||
not #request->contains('\r\n\r\n')? currentCapture->restart
|
||||
}()
|
||||
|
||||
local(response) = 'HTTP/1.1 200 OK\r\n\
|
||||
Content-Type: text/html; charset=UTF-8\r\n\r\n\
|
||||
Goodbye, World!'
|
||||
#con->writeBytes(bytes(#response))
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import asynchttpserver, asyncdispatch
|
||||
|
||||
proc cb(req: Request) {.async.} =
|
||||
await req.respond(Http200, "Hello, World!")
|
||||
|
||||
asyncCheck newAsyncHttpServer().serve(Port(8080), cb)
|
||||
runForever()
|
||||
|
|
@ -0,0 +1 @@
|
|||
8080.port.listen.say("Hello world!")
|
||||
57
Task/Hello-world-Web-server/Ring/hello-world-web-server.ring
Normal file
57
Task/Hello-world-Web-server/Ring/hello-world-web-server.ring
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
Load "guilib.ring"
|
||||
|
||||
cResponse = "HTTP/1.1 200 OK\r\n" +
|
||||
"Content-Type: text/html\r\n\r\n" +
|
||||
"<html><head><title>Goodbye, world!</title></head>" +
|
||||
"<body>Goodbye, world!</body></html>"
|
||||
|
||||
cResponse = substr(cResponse,"\r\n",char(13)+char(10))
|
||||
|
||||
new qApp {
|
||||
oServer = new Server { Server() }
|
||||
exec()
|
||||
}
|
||||
|
||||
Class Server
|
||||
|
||||
win1 lineedit1
|
||||
oTcpServer oTcpClient
|
||||
cOutput = ""
|
||||
|
||||
func server
|
||||
|
||||
win1 = new qwidget()
|
||||
|
||||
lineedit1 = new qtextedit(win1) {
|
||||
setGeometry(150,50,200,300)
|
||||
}
|
||||
|
||||
win1 {
|
||||
setwindowtitle("Server")
|
||||
setgeometry(450,100,400,400)
|
||||
show()
|
||||
}
|
||||
|
||||
oTcpServer = new qTcpServer(win1) {
|
||||
setNewConnectionEvent("oServer.pNewConnection()")
|
||||
oHostAddress = new qHostAddress()
|
||||
oHostAddress.SetAddress("127.0.0.1")
|
||||
listen(oHostAddress,8080)
|
||||
}
|
||||
cOutput = "Server Started" + nl +
|
||||
"listen to port 8080" + nl
|
||||
|
||||
lineedit1.settext(cOutput)
|
||||
|
||||
Func pNewConnection
|
||||
|
||||
oTcpClient = oTcpServer.nextPendingConnection()
|
||||
while not oTcpClient.waitForReadyRead(100) end
|
||||
cOutput += "Accept Connection" + nl
|
||||
lineedit1.settext(cOutput)
|
||||
oTcpClient {
|
||||
write(cResponse,len(cResponse))
|
||||
flush()
|
||||
waitforbyteswritten(300000)
|
||||
close()
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
var port = 8080;
|
||||
var protocol = Socket.getprotobyname("tcp");
|
||||
|
||||
var sock = (Socket.open(Socket.PF_INET, Socket.SOCK_STREAM, protocol) || die "couldn't open a socket: #{$!}");
|
||||
# PF_INET to indicate that this socket will connect to the internet domain
|
||||
# SOCK_STREAM indicates a TCP stream, SOCK_DGRAM would indicate UDP communication
|
||||
|
||||
sock.setsockopt(Socket.SOL_SOCKET, Socket.SO_REUSEADDR, 1) || die "couldn't set socket options: #{$!}";
|
||||
# SOL_SOCKET to indicate that we are setting an option on the socket instead of the protocol
|
||||
# mark the socket reusable
|
||||
|
||||
sock.bind(Socket.sockaddr_in(port, Socket.INADDR_ANY)) || die "couldn't bind socket to port #{port}: #{$!}";
|
||||
# bind our socket to $port, allowing any IP to connect
|
||||
|
||||
sock.listen(Socket.SOMAXCONN) || die "couldn't listen to port #{port}: #{$!}";
|
||||
# start listening for incoming connections
|
||||
|
||||
while (var client = sock.accept) {
|
||||
client.print ("HTTP/1.1 200 OK\r\n" +
|
||||
"Content-Type: text/html; charset=UTF-8\r\n\r\n" +
|
||||
"<html><head><title>Goodbye, world!</title></head>" +
|
||||
"<body>Goodbye, world!</body></html>\r\n");
|
||||
client.close;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
var inet = require('IO::Socket::INET');
|
||||
|
||||
var sock = inet.new( LocalAddr => "127.0.0.1:8080",
|
||||
Listen => 1,
|
||||
Reuse => 1,
|
||||
);
|
||||
|
||||
while (var client = sock.accept) {
|
||||
client.print ("HTTP/1.1 200 OK\r\n" +
|
||||
"Content-Type: text/html; charset=UTF-8\r\n\r\n" +
|
||||
"<html><head><title>Goodbye, world!</title></head>" +
|
||||
"<body>Goodbye, world!</body></html>\r\n");
|
||||
client.close;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
with server_socket socket :port 4000
|
||||
accepting client :from socket
|
||||
making stdout outfile+fd.client
|
||||
prn "HTTP/1.0 200 OK"
|
||||
prn "Content-type: text/plain"
|
||||
prn ""
|
||||
prn "Hello, world!"
|
||||
Loading…
Add table
Add a link
Reference in a new issue