Forums
A .NET web server
9 posts
• Page 1 of 1
A .NET web server
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
Cool. Been looking for something like this.
A loose translation of Tutorial1 behaved as expected:
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
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.
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
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
-- 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
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
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
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.)
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
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.
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
This is a better loop. Doesn't burn up the CPU:
while .isRunning, Threading.Thread.sleep(750)
- Charles
- Posts: 2515
- Location: Los Angeles, CA
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 84 guests