PB CGI / Spiderbasic issues [solved]

Just starting out? Need help? Post your questions and find answers here.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

PB CGI / Spiderbasic issues [solved]

Post 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?
Last edited by kinglestat on Mon Apr 29, 2024 2:48 pm, edited 1 time in total.
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: PB CGI / Spiderbasic issues

Post 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
Image Image
User avatar
idle
Always Here
Always Here
Posts: 6029
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PB CGI / Spiderbasic issues

Post 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
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Re: PB CGI / Spiderbasic issues

Post 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
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
User avatar
the.weavster
Addict
Addict
Posts: 1581
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: PB CGI / Spiderbasic issues

Post 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 ).
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Re: PB CGI / Spiderbasic issues

Post by kinglestat »

https worked; so its an IIS issue
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Re: PB CGI / Spiderbasic issues [solved]

Post 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
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Post Reply