Page 1 of 1

PB CGI / Spiderbasic issues [solved]

Posted: Sat Apr 27, 2024 3:07 pm
by kinglestat
I am trying my first server/client app. Server side I have IIS 7 on Windows server 12R2 and am using test examples found on the forum though dated
I have enabled cgi on IIS

PB App

Code: Select all

If Not InitCGI() Or Not ReadCGI()
  End
EndIf

name$=CGIParameterValue("name")

WriteCGIHeader(#PB_CGI_HeaderContentType,"text/html",#PB_CGI_LastHeader)
WriteCGIString("Hello "+name$)
SB Code

Code: Select all

;/ Created with PureVision v5.40
;/ Mon, 09 Nov 2015 11:45:45
;/ by Paul Leischow


Define EventID,MenuID,GadgetID,WindowID

;- Window Constants
Enumeration 1
  #Window_Main
EndEnumeration

;- Gadget Constants
Enumeration 1
  ;Window_Main
  #Gadget_Main_Text2
  #Gadget_Main_Name
  #Gadget_Main_OK
EndEnumeration

Procedure.i Window_Main()
  If OpenWindow(#Window_Main,158,117,335,84,"CGI Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
      TextGadget(#Gadget_Main_Text2,15,15,60,15,"Name:")
      StringGadget(#Gadget_Main_Name,15,30,230,20,"")
      ButtonGadget(#Gadget_Main_OK,255,30,60,20,"OK")
      HideWindow(#Window_Main,0)
    ProcedureReturn WindowID(#Window_Main)
  EndIf
EndProcedure

Procedure HttpGetEvent(Success, Result$, UserData)
   If Success
      debug "======================================="
      Debug Result$
      debug "======================================="
      debug UserData
    Else
    Debug "HTTPRequest(): Error"
  EndIf
 EndProcedure
 
Procedure CloseWindowEvent()
  WindowID=EventWindow()
  If WindowID=#Window_Main
    CloseWindow(#Window_Main)
  EndIf
EndProcedure

;- GadgetEvent Loop
Procedure GadgetEvent()
  GadgetID=EventGadget()

  Select GadgetID
    Case #Gadget_Main_OK
      HTTPRequest(#PB_HTTP_Get, "http://localhost/test/cgi-bin/cgitest.exe?name="+GetGadgetText(#Gadget_Main_Name), "", @HttpGetEvent())
  EndSelect
EndProcedure

;- Main Loop
If Window_Main()
  BindEvent(#PB_Event_Gadget,@GadgetEvent())
EndIf
the issue is I get garbage, then some assemble information rather than the expected "Hello <name>"

the output
https://gyazo.com/397bf71f4b30a28dcff2abfde32134f4


Is this a bug?

Re: PB CGI / Spiderbasic issues

Posted: Sat Apr 27, 2024 3:33 pm
by Paul
Most likely Server setup issue or CORS policy issue on your end.
Did you open the Developer console in you browser and see what error is occurring when you send the request?

If you want to test it on my Server just change...

Code: Select all

HTTPRequest(#PB_HTTP_Get, "http://localhost/test/cgi-bin/cgitest.exe?name="+GetGadgetText(#Gadget_Main_Name), "", @HttpGetEvent())
to

Code: Select all

HTTPRequest(#PB_HTTP_Get, "http://reelmedia.org/cgi-bin/cgitest.exe?name="+GetGadgetText(#Gadget_Main_Name), "", @HttpGetEvent())

This should be posted on SpiderBasic forum, not here

Re: PB CGI / Spiderbasic issues

Posted: Sun Apr 28, 2024 1:39 am
by idle
Have you tried atomic web server 3
It replaces the need to use CGI or interpreted languages via Uri Handlers and Html preprocessor and is ideal for hosting Spiderbasic apps among other things, eventually once I've add the virtual file system you will then be able to compile and distribute it as a single exe with no dependencies to serve the spider basic app to a web gadget or users browser.

https://www.purebasic.fr/english/viewtopic.php?t=83780

Re: PB CGI / Spiderbasic issues

Posted: Sun Apr 28, 2024 5:47 am
by kinglestat
@paul
I get error when I tried with your link

@idle
There are already sites and programs using IIS, so changing server is definitely out of the question plus the mechanics should work whatever server is used

And I am not sure which side has the bug, and PB has many more users than SB

Re: PB CGI / Spiderbasic issues

Posted: Sun Apr 28, 2024 10:48 am
by the.weavster
kinglestat wrote: Sun Apr 28, 2024 5:47 am @paul
I get error when I tried with your link
It worked for me.
Try changing http to https in Paul's url and give that a go ( I think Firefox does that automatically for me ).

Re: PB CGI / Spiderbasic issues

Posted: Sun Apr 28, 2024 1:47 pm
by kinglestat
https worked; so its an IIS issue

Re: PB CGI / Spiderbasic issues [solved]

Posted: Sun Apr 28, 2024 2:16 pm
by kinglestat
thanks for the help guys. It was an IIS issue. for those interested the following steps make the magic work

https://www.greyware.com/kb/KB2005.502.asp