[Coco] The Coco's first webserver, written in Basic09

Aaron Wolfe aawolfe at gmail.com
Wed Dec 30 14:09:36 EST 2009


Well it looks like the patches to the Java side are holding.. a couple
hours of up time now.

I'm going to be taking the site down soon so I can add some new
features, maybe we'll have an image on the page later today.

-Aaron

On Wed, Dec 30, 2009 at 12:09 PM, John Donaldson
<johnadonaldson at sbcglobal.net> wrote:
> WOW.....very neat. Web Page came up real fast too. Then too it is ALL text
> and that makes it fast. Wonder if you could try and include a small JPEG of
> a COCO3. Then you would have a Web Server with graphics.
>
> John Donaldson
>
> Tom Seagrove wrote:
>>
>> The beginning of a new era in CoConess...
>>
>> Great job on pushing the limits and that goes to everyone who has been
>> developing lately...keep up the great work!!
>>
>> Tom
>>
>> -----Original Message-----
>> From: coco-bounces at maltedmedia.com [mailto:coco-bounces at maltedmedia.com]
>> On
>> Behalf Of Aaron Wolfe
>> Sent: Wednesday, December 30, 2009 10:02 AM
>> To: CoCoList for Color Computer Enthusiasts
>> Subject: [Coco] The Coco's first webserver, written in Basic09
>>
>> Hi folks,
>>
>> The Coco is now serving up web pages.. I guess it was only a matter of
>> time
>> :)
>>
>> http://home.spogbiper.com/
>>
>> Not much to look at, but all HTTP is processed and all HTML is
>> generated by the Coco.
>> All that drivewire is doing is passing raw data from TCP socket to the
>> Coco over a DriveWire virtual channel.
>>
>> The source for the web server is below.  I hope it serves as an
>> example of how easy it is to use the new features in drivewire to
>> write programs that talk to the outside world.
>>
>> It can easily be improved to do much more.  I plan to have it serving
>> up files and show directory listings for Coco disks soon.  You'll be
>> able to browse files on your Coco using a browser and fun things like
>> that.
>>
>> As a side note, I added "weather" command to my test coco that will
>> show you the weather for many cities or zip codes.
>>
>>
>> Basic09 source for "httpd" (please don't laugh, its my first Basic09
>> program):
>>
>>
>>
>> PROCEDURE httpd
>> DIM port_path:BYTE
>> DIM port_name:STRING[4]
>> DIM errnum,tmp:INTEGER
>> DIM reqstr:STRING
>> DIM reqid:BYTE
>> TYPE servin = id:BYTE; control:BYTE; dat:STRING[128]
>>
>> DIM srv_in:servin
>> DIM hits:INTEGER
>>
>> port_name="/U0"
>> hits=0
>>
>> ON ERROR GOTO 100
>> 10 OPEN #port_path,port_name:UPDATE
>>
>>   PRINT "USING UTILITY PORT ";port_name
>>   GOTO 30
>>
>> 20 PRINT "TRY NEXT"
>>   tmp := PEEK(ADDR(port_name)+2)
>>   tmp := tmp + 1
>>   POKE ADDR(port_name) + 2, tmp
>>   GOTO 10
>>
>> 30 PRINT "MAIN LOOP"
>>   ON ERROR GOTO 200
>>
>>   PRINT #port_path,"httpd"
>>   PRINT #port_path,"start"
>>
>>   REPEAT
>>
>>     REPEAT
>>       GET #port_path,srv_in
>>
>>       IF LEFT$(srv_in.dat,3) = "GET" THEN
>>         reqstr = TRIM$(RIGHT$(srv_in.dat,124))
>>         reqid = srv_in.id
>>       ENDIF
>>
>>     UNTIL (srv_in.control = 1) OR (srv_in.control = 0)
>>
>>     hits = hits + 1
>>
>>     IF srv_in.control = 1 THEN
>>          print "REQUEST",reqstr
>>
>>          IF LEFT$(reqstr,2) = "/ " THEN
>>          PRINT #port_path,"HTTP/1.1 200 OK"
>>          PRINT #port_path,"Server: COCO OS9 DriveWire"
>>          PRINT #port_path,"Connection: close"
>>          PRINT #port_path,""
>>          PRINT #port_path,"<HTML>"
>>          PRINT #port_path,"<BODY BGCOLOR=#33FF33>"
>>          PRINT #port_path,"<P><CENTER><H1>coco!</h1><P>"
>>          PRINT #port_path,"<h4>This page is served by a Color Computer
>> 3<BR>"
>>          PRINT #port_path,"running <A
>> HREF=http://www.nitros9.org/>NitrOS-9</A>"
>>          PRINT #port_path,"and <A
>>
>> HREF=http://www.frontiernet.net/%7Emmarlette/Cloud-9/Software/DriveWire3.htm
>> l>DriveWire</A>"
>>          PRINT #port_path," <P>For more information on this
>> project, <A HREF=http://aaronwolfe.com/coco>click here</A><P>"
>>          PRINT #port_path,"This server has processed "
>>          PRINT #port_path,hits
>>          PRINT #port_path," requests since it last crashed.</H4>"
>>          PRINT #port_path,"</BODY>"
>>          PRINT #port_path,"</HTML>"
>>          PRINT #port_path,CHR$(0)
>>          ELSE
>>            GOSUB 1000
>>          ENDIF
>>
>>     ENDIF
>>
>>   UNTIL srv_in.control = 0
>>
>>   CLOSE #port_path
>>   END
>>
>> 100 errnum := ERR
>>   IF errnum = 250 THEN
>>      PRINT "BUSY ON PORT ",port_name
>>      GOTO 20
>>   ELSE
>>      PRINT "ERROR ", errnum, " ON PORT ", port_name
>>      END
>>   ENDIF
>>
>>
>> 200 errnum := ERR
>>  PRINT "ERROR ", errnum
>>  CLOSE #port_path
>>  END
>>
>> 1000   PRINT #port_path,""
>>  PRINT #port_path,CHR$(0)
>>
>>  RETURN
>>
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> http://five.pairlist.net/mailman/listinfo/coco
>>
>>
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> http://five.pairlist.net/mailman/listinfo/coco
>>
>>
>
>
> --
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco
>



More information about the Coco mailing list