I have the following code on a Purebasic program (CGI) and I am using Abyss web server. I know the Purebasic-CGI works because I get the correct reply on a regular webpage http://127.0.0.1/cgi-bin/test.exe.
When I do a httprequest() on Spiderbasic I get an HTTP: Request error
;Initialize CGI and make sure we are able to read request
If Not InitCGI() Or Not ReadCGI()
End
EndIf
;Create Body of page
jsonresponse.s = "{'name':'This should work'}"
WriteCGIHeader("Access-Control-Allow-Origin", "*")
WriteCGIHeader(#PB_CGI_HeaderContentType, "text/html", #PB_CGI_LastHeader)
WriteCGIString(jsonresponse)
; Test interaction between SpiderBasic And Purebasic CGI
theurl.s = "http://127.0.0.1/cgi-bin/test.exe"
Procedure HttpGetEvent(Success, Result$, UserData)
If Success
Debug Result$
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
; Get the content of this file, and display it in the debug window
Debug "Sending Request to " + theurl
;
HTTPRequest(#PB_HTTP_Post, theurl, "", @HttpGetEvent())
This weekend I will do some kind of instructions on how to configure CGI to run a Purebasic .exe
I will also put some example code for Purebasic CGI.
So basically there are 3 components to make it all work:
1) Abyss Webserver running CGI
2) Purebasic executable receiving the HTTP_Request, accessing a SQLITE database, and returning JSON
3) Spiderbasic for the web interface and to send requests and to process the JSON responses.
It all works pretty good.
I really don't need to learn HTML5, CSS, Javascript, and a Server scripting language like PHP, Python, etc.
*** I am no expert but I do want Spiderbasic to become a viable alternative for web programming.
Very much appreciated.
In my instance it will differ a little but the base code should be very close. My server is MS server 2008, so I will be using IIS CGI. And the database is MS SQL server 2008 R2 which doesn't support JSON so I will be passing XML instead.
Looking forward to it.
Cheers ....