Here is a sample of client / server comms in spiderbasic / purebasic
When you click the button it sends string to cgi which uppers the string and sends back the result
Spiderbasic will then update the textgadget
You need the CGI Lib for Purebasic for server end.
You also need to run the Spiderbasic and the CGI Purebasic from the same webserver to avoid cross domain request problems.
i.e. it will not work from the IDE with default Apache setup
In my example both are served from a local Apache server on Windows box.
You also have to configure Apache to allow CGI etc.
However you can make it work from IDE by modifying the following in Apache.
Add in mod_headers.so
and in Directory section add
Header set Access-Control-Allow-Origin "*"
Handy for testing only......
Spiderbasic
Code: Select all
Procedure UpperWeb(Success, Result$)
If Success
SetGadgetText(3,Result$)
Else
Debug "Failed"
EndIf
EndProcedure
Procedure getbutton()
temp$=GetGadgetText(3)
HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/upper.pbe?string="+temp$, "", @UpperWeb())
EndProcedure
If OpenWindow(1, 100, 100, 250, 75, "Test", #PB_Window_TitleBar)
ButtonGadget(2, 20, 30, 75, 30, "To Upper")
StringGadget(3, 120, 30, 75, 30, "abc")
BindGadgetEvent(2,@getbutton(), #PB_EventType_LeftClick )
EndIf
Purebasic
Code: Select all
CGI_In()
string$=CGI_Val("string")
string$=UCase(string$)
CGI_Header()
CGI_Out(string$)
End