Page 1 of 1

PureBasic Server Pages - possible?

Posted: Wed Mar 26, 2014 7:58 pm
by es_91
I have no idea.

My question is if it is possible to create an object oriented language to be bound into an html code to create server-side scriptcode in PureBasic. This is like ASP or JSP. I would like to have something like that because it really suxx to write code in Java and Visual Basic... imo is not a real Basic.

After all, PureBasic code could easily be wrapped into OOP, for example ...

Code: Select all

  Window = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, 640, 480, "MyWindow", #PB_Window_SystemMenu|#PB_Window_Invisible)
  HideWindow(Window, #False)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
... could be translated into ...

Code: Select all

  Declare Window_Close()
  
  Window = New PureBasic.Window()
  Window.ID = #PB_Any
  Window.X = #PB_Ignore
  Window.Y = #PB_Ignore
  Window.Width = 640
  Window.Height = 480
  Window.Title$ = "MyWindow"
  Window.Flags = #PB_Window_SystemMenu|#PB_Window_Invisible
  Window.Create()
  Window.Hide(#False)
  
  Window.WindowEvents.CloseWindow = @Window_Close()
  
  Procedure Window_Close()
    End
  EndProcedure
.

What do you think?

Re: PureBasic Server Pages - possible?

Posted: Wed Mar 26, 2014 9:16 pm
by netmaestro
Would cgi serve your purpose? I believe Paul has a cgi library and others here (rings, infratec off the top of my head) have experience implementing cgi in PureBasic. For server side scripting, that would seem your best bet.

Re: PureBasic Server Pages - possible?

Posted: Wed Mar 26, 2014 9:43 pm
by es_91
Well... yeah. I will try that. But what i had in mind, it now gets clear to me, was an own web server serving PureBasic support. As far as i understand cgi does use standart web serving technology, alowing to bind in several languages. (So, is it possible to use freeBasic with cgi? I'd have to read about stdout and stdin as well as environment variables, i understand.) But what i wanted was a real PureBasic support. Like that:

Code: Select all

<HTML>
  <HEAD>
  </HEAD>
  <BODY>
    <$ Page.PrintN("The time is: "+FormatDate("%hh:%ii:%ss", Date())) $>
  </BODY>
</HTML>
... giving ...

Code: Select all

<HTML>
  <HEAD>
  </HEAD>
  <BODY>
    <p>
      The time is: 21:43:25
    </p>
  </BODY>
</HTML>
CGI is slow, right? So an own web server would be better or am i underestimating the efforts needed to create a fully usable own web server?

Re: PureBasic Server Pages - possible?

Posted: Thu Mar 27, 2014 8:51 pm
by the.weavster
Check out nodejs for the server, it's hard to beat, both for ease and performance.

Wherever possible I'd recommend creating a single page web app and a remote procedure call server that pass JSON back and forth rather than embedding scripts in HTML.