Oldbitcollector (Jeff)
07-03-2011, 10:50 PM
Been doing some fiddling with MikeG's webserver code.
I may have found a "best of both worlds" way to add some direction spin-to-html controls along with the clever .js stuff that is currently in it.
Here's my changes
PRI Dispatcher(id) | bypass
{ }
bypass := 0
'' Spin code Generated webpage
'' Checks for commandline entries
if(strcomp(Request.GetName(id), string("hello")))
Index(id)
DisplayStuff(id)
bypass:=1 '' Don't look for actual file.
if(strcomp(Request.GetName(id), string("post")))
Post(id)
if(strcomp(Request.GetName(id), string("upload")))
Upload(id)
if(strcomp(Request.GetName(id), string("ajax")))
Ajax(id)
if(strcomp(Request.GetName(id), string("getdir")))
GetDir(id)
return
if(strcomp(Request.GetName(id), string("gettime")))
GetTime(id)
return
if(strcomp(Request.GetName(id), string("firmware")))
Firmware(id)
return
if bypass == 0
StaticFileHandler(id)
return
{ }
PRI Index(id)
pst.str(string(13, "Index Processor", 13))
'pst.str(string("led := "))
led:=str2dec((Request.Get(id, string("led"))))
'pst.dec(led)
if led == 208
pst.str(string("LED is OFF"))
outa[23]:=0
if led == 218
pst.str(string("LED is ON"))
outa[23]:=1
pst.char(13)
pst.str(string("this := "))
pst.str(Request.Get(id, string("this")))
pst.char(13)
return
{ }
PRI DisplayStuff(id) | headerLen
''Build HTML Header
headerLen := Response.BuildHeader(Request.GetExtension(id), 200, false)
Socket.txTCP(id, @txdata, headerLen)
StringSend(id, string("<form>",13,10))
StringSend(id, string("<input type=radio name=led value=1 /> Led On<br /> ",13,10))
StringSend(id, string("<input type=radio name=led value=0 /> Led Off ",13,10))
StringSend(id, string("<form>",13,10))
StringSend(ID, string("<input type=submit /> Change the State of LED."))
PUB str2dec(stri) | index2
result := 0
repeat index2 from 0 to strsize(stri)
result *= 10
result += byte[stri][index2] - "0"
I may have found a "best of both worlds" way to add some direction spin-to-html controls along with the clever .js stuff that is currently in it.
Here's my changes
PRI Dispatcher(id) | bypass
{ }
bypass := 0
'' Spin code Generated webpage
'' Checks for commandline entries
if(strcomp(Request.GetName(id), string("hello")))
Index(id)
DisplayStuff(id)
bypass:=1 '' Don't look for actual file.
if(strcomp(Request.GetName(id), string("post")))
Post(id)
if(strcomp(Request.GetName(id), string("upload")))
Upload(id)
if(strcomp(Request.GetName(id), string("ajax")))
Ajax(id)
if(strcomp(Request.GetName(id), string("getdir")))
GetDir(id)
return
if(strcomp(Request.GetName(id), string("gettime")))
GetTime(id)
return
if(strcomp(Request.GetName(id), string("firmware")))
Firmware(id)
return
if bypass == 0
StaticFileHandler(id)
return
{ }
PRI Index(id)
pst.str(string(13, "Index Processor", 13))
'pst.str(string("led := "))
led:=str2dec((Request.Get(id, string("led"))))
'pst.dec(led)
if led == 208
pst.str(string("LED is OFF"))
outa[23]:=0
if led == 218
pst.str(string("LED is ON"))
outa[23]:=1
pst.char(13)
pst.str(string("this := "))
pst.str(Request.Get(id, string("this")))
pst.char(13)
return
{ }
PRI DisplayStuff(id) | headerLen
''Build HTML Header
headerLen := Response.BuildHeader(Request.GetExtension(id), 200, false)
Socket.txTCP(id, @txdata, headerLen)
StringSend(id, string("<form>",13,10))
StringSend(id, string("<input type=radio name=led value=1 /> Led On<br /> ",13,10))
StringSend(id, string("<input type=radio name=led value=0 /> Led Off ",13,10))
StringSend(id, string("<form>",13,10))
StringSend(ID, string("<input type=submit /> Change the State of LED."))
PUB str2dec(stri) | index2
result := 0
repeat index2 from 0 to strsize(stri)
result *= 10
result += byte[stri][index2] - "0"