I don't see a single reason why would you do so.Peter wrote:Consequently, you would have to use GopherJS or the Joy Compiler now.bbanelli wrote:Instead, for server side, consider GoLang.
Go
Code: Select all
package main
import (
"encoding/json"
"net/http"
)
type spiderStruct struct {
NavigatorPlatform string `json:"navigatorPlatform"`
}
func spiderTest(w http.ResponseWriter, r *http.Request) {
decoder := json.NewDecoder(r.Body)
var spiderJson spiderStruct
decoder.Decode(&spiderJson)
w.Write([]byte(spiderJson.NavigatorPlatform + " - Go!"))
}
func main() {
fs := http.FileServer(http.Dir("static"))
http.Handle("/", fs)
http.HandleFunc("/spiderPost", spiderTest)
http.ListenAndServe(":8080", nil)
}
Code: Select all
Procedure HttpGetEvent(Success, Result$, UserData)
If Success
Debug Result$
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
Procedure ButtonHandler()
Protected.s s
!v_s = navigator.platform;
s = ~"{\"navigatorPlatform\": \"" + s + ~"\"}"
HTTPRequest(#PB_HTTP_Post, "/spiderPost", s, @HttpGetEvent())
EndProcedure
If OpenWindow(0, 100, 100, 320, 240, "", #PB_Window_SizeGadget)
ButtonGadget(0, 10, 10, 100, 20, "Click me")
EndIf
BindGadgetEvent(0, @ButtonHandler())
Go is serving both static SpiderBasic files and provides HTTP request endpoints.
I seriously have to answer that?the.weavster wrote:Why? CGI is wonderfully simple and simple solutions are invariably the most robust.bbanelli wrote:I know this is an old topic, but I would strongly discourage using (any, let alone PB's) CGI in 2019.
CGI is a Internet atavism, server and platform dependent, incompatible with any modern relevant technology for deployment, calls/forks new process with each request making reuse of connections and objects impossible, its last specification is 15+ years old, has no support for any sane modern approach of HTTP communication, it is very hard to debug... I could go on but it would be pointless.
In other words, there is nothing "robust" or "simple" in CGI; especially not in 2019. Not even as a joke. And you seemed to be pretty serious. Which is very bad, very bad, since someone could actually believe you.