Forums

A .NET web server

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

A .NET web server

Postby Charles » Fri May 22, 2009 1:33 pm

Anyone care to check this out and try it with Cobra? http://www.codeplex.com/webserver
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: A .NET web server

Postby khjklujn » Wed May 27, 2009 11:03 am

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
khjklujn
 
Posts: 29

Re: A .NET web server

Postby Charles » Wed May 27, 2009 2:19 pm

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.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: A .NET web server

Postby Charles » Mon Jun 01, 2009 9:53 pm

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
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: A .NET web server

Postby jgauffin » Fri Jun 12, 2009 1:55 am

If you need any fixes in the webserver, let me know and I'll take a look at it.
jgauffin
 
Posts: 2

Re: A .NET web server

Postby jgauffin » Fri Jun 12, 2009 1:56 am

Let me know if you need any fixes in the webserver to get everything running smoothly in Cobra.
jgauffin
 
Posts: 2

Re: A .NET web server

Postby Charles » Tue Jun 16, 2009 2:32 am

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.)
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: A .NET web server

Postby Charles » Wed Jun 17, 2009 10:52 pm

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.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: A .NET web server

Postby Charles » Sat Jun 20, 2009 9:01 pm

This is a better loop. Doesn't burn up the CPU:
while .isRunning, Threading.Thread.sleep(750)
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 97 guests

cron