Page 1 of 1

A .NET web server

PostPosted: Fri May 22, 2009 1:33 pm
by Charles
Anyone care to check this out and try it with Cobra? http://www.codeplex.com/webserver

Re: A .NET web server

PostPosted: Wed May 27, 2009 11:03 am
by khjklujn
Cool. Been looking for something like this.

A loose translation of Tutorial1 behaved as expected:

use System.Net
use HttpServer

class Test

pro running from var = false
get listener from var = HttpServer.HttpListener.create(IPAddress.any, 8081)

cue init
base.init

print 'Browse to <!-- m --><a class="postlink" href="http://localhost:8081/hello">http://localhost:8081/hello</a><!-- m --> to view the contents
print 'and <!-- m --><a class="postlink" href="http://localhost:8081/bye">http://localhost:8081/bye</a><!-- m --> to shut down the server.'

listen .listener.requestReceived, ref .onRequest

.listener.start(5)
.running = true

def onRequest(source, args as RequestEventArgs?)
context = source to IHttpClientContext
request = args.request

if request.uri.absolutePath == '/hello'
context.respond('Hello to you too!')

else if request.uriParts.length == 1 and request.uriParts[0] == 'bye'
response = HttpResponse(context, request)
writer = StreamWriter(response.body)
writer.writeLine('Goodbye to you too!')
writer.flush
response.send
.listener.stop
.running = false

else
context.respond('Nope: [request.uri.absolutePath]')

test
t = Test()
while t.running
pass

Re: A .NET web server

PostPosted: Wed May 27, 2009 2:19 pm
by Charles
That's great! Thanks!

Can you point it to a directory to load files from like "hello.cobra" and "bye.cobra"? If so it probably needs some kind of "adapter" to handle files of a given extension.

Re: A .NET web server

PostPosted: Mon Jun 01, 2009 9:53 pm
by Charles
I'd still love to see more done with this including a sample web site. But I currently have the following coming up:
-- patch applications
-- add attribute capabilities requested by gauthier
-- release
-- monthly update
-- a presentation this month
-- jvm back-end
-- 5 more things that will come up in the next 2 weeks

Re: A .NET web server

PostPosted: Fri Jun 12, 2009 1:55 am
by jgauffin
If you need any fixes in the webserver, let me know and I'll take a look at it.

Re: A .NET web server

PostPosted: Fri Jun 12, 2009 1:56 am
by jgauffin
Let me know if you need any fixes in the webserver to get everything running smoothly in Cobra.

Re: A .NET web server

PostPosted: Tue Jun 16, 2009 2:32 am
by Charles
Thanks. You're the author of "C# WebServer", yes?

I really like the idea of an independent, open source app server. I wrote one for Python (Webware/WebKit) but don't have time to write one for Cobra.

We really just need a better example of making a real, dynamic site with this and Cobra. And maybe that also entails some integration work. We'll see.

(Sorry your message didn't get approved sooner. I'm still getting used to the moderator interface which splits new messages into 2 tabs.)

Re: A .NET web server

PostPosted: Wed Jun 17, 2009 10:52 pm
by Charles
I've added a wiki page at SharpWebServer. Not much there, but we can add notes as we pick up more experience.

Also, I tested whether it works on Novell Mono on Mac and it does.

I think my next step will be to build it out of their repository as I see some activity there with fixes and refinements.

Re: A .NET web server

PostPosted: Sat Jun 20, 2009 9:01 pm
by Charles
This is a better loop. Doesn't burn up the CPU:
while .isRunning, Threading.Thread.sleep(750)