Od: "Domenico D'Oria" <nikk...@gmail.com>
Do: harbou...@googlegroups.com;
Wysłane: 17:17 Środa 2013-10-16
Temat: [harbour] mongoose embedded web server + harbour interpreter, why not ?
[...]
first i'm not a c expert , but reading this page
http://cesanta.com/docs.html#docs/FAQ.md
I was struck by a flash.
Could be a good idea porting the harbour interpreter to this server ?
Hi,
In the Harbor is all you need. SqlLite, www server and scripts host. And many, many more.
Regards,
Marek Horodyski
Od: "Domenico D'Oria" <nikk...@gmail.com>
Do: harbou...@googlegroups.com;
Wysłane: 11:47 Czwartek 2013-10-24
Temat: Re: [harbour] mongoose embedded web server + harbour interpreter, why not ?
Hi homar
after a lot of time surf and search the web, i try to explain better my question.
i know there is webserver like hbttpd written in harbour, but the question is : can this good piece of software be able to "interprete" harbour as a scripting language, like php or for example lua ? or asp vbscript for the incoming standards like html5.
or we must use it as a programming language ? as showed in the examples.
best regards
Hi Domenico
You can use scripts like in php. In example in \harbour\examples\httpsrv\ they are as cgi. But two examples \harbour\examples\httpsrv\ and \harbour\contrib\hbhttpd\ are very difficult to analisys.
My anglish is limited, but in the evening I will try to send circa 600 lines code http server based on this example serwer with runing scripts.
Regards,
Marek Horodyski
Od: "Domenico D'Oria" <nikk...@gmail.com>
Do: harbou...@googlegroups.com;
Wysłane: 11:47 Czwartek 2013-10-24
Temat: Re: [harbour] mongoose embedded web server + harbour interpreter, why not ?
Hi homar
after a lot of time surf and search the web, i try to explain better my question.
i know there is webserver like hbttpd written in harbour, but the question is : can this good piece of software be able to "interprete" harbour as a scripting language, like php or for example lua ? or asp vbscript for the incoming standards like html5.
or we must use it as a programming language ? as showed in the examples.
best regards
Hi Domenico
In attachment are simple http server based on Mindaugas code with execute scripts.
You can adapt it to your needs.
How it work ?
I run it from another script :) You can from exe (at the beginning).
Runing code from my script :
//====================
local o := HttpServer():new(), n
cls
hb_gtInfo( 26, "http_Server")
o:nPort := 80 //02
o:lRejestr := .f.
o:lConnect := .t.
o:nPartTime := 1 / 86400 * 16 // domyślny czas podtrzymania połaczenia
o:cFileStartPage := "index.html" // old version, mabe form script, see in line 396.
o:cPathHttpFiles := "\homar\httpFiles\"
o:cPathBossFiles := "\homar\BossFiles\"
o:cPathTempFiles := "\homar\tempFiles\"
// o:cPathBossFiles := "\homar\BossFiles\"
if !o:Run() // <-- here is runing server
? 'Error :', o:cError
end
? len( o:aThreads)
? o:cError
for n := 1 to len( o:adbConnect) ; if( valType( o:adbConnect[ n][ 3]) == 'N', rddInfo( 1002, o:adbConnect[ n][ 3]), o:adbConnect[ n][ 3] := Nil)
end
__Wait( 'hit any key ...')
Return
// ============= end script
From this moment serwer read port 80.
In alter version worked only in intranet with one domain in path o:cPathBossFiles := "\homar\BossFiles\" are was scripts. But now server hosted many domains, and script file must be in another way examined. In this algorytm are file extension ( like .php in PHP).
In folder o:cPathHttpFiles you can create folders for domains. In my case are 4 folders with '.pl' extensions :
╔════════════ D:\homar\httpFiles ═════════[]═╗
║ Name │ Size │ Date │Time
║.. │<UP--DIR>│13-10-26│02:23▒
║harbour-project pl│<SUB-DIR>│13-09-09│04:51▒
║marekhorodyski pl│<SUB-DIR>│13-07-29│19:12▒
║horodyscy pl│<SUB-DIR>│13-07-18│23:42▒
║marek-horodyski pl│<SUB-DIR>│13-07-16│22:38▒
║favicon ico│ 4,286│11-04-27│03:03▒
║ajax-loader gif│ 1,644│09-01-20│01:40▒
║ │ │ │ ▒
║ │ │ │ ▒
Od: marek.h...@interia.pl
Do: harbou...@googlegroups.com;
Wysłane: 4:00 Sobota 2013-10-26
Temat: Re: [harbour] mongoose embedded web server + harbour interpreter, why not ?
[...]
You can change ".pl' to your contry symbol - in 385 line.You can test it when click http://89.77.33.3/( I see that now is no access from the outside - I think I was late paying bill :) But try on Monday)
Oh, after half a year changed my IP adress to 89.68.115.131. Now work with this IP.
One more note : in standard errorSys procedure I make so change :
Function ErrorSys( e)
Static tdz
Local cMessage, aOptions, nChoice, v := V(), www := topProcName() == 'SOCKETCONNECTION'
Local osc := ";( DOS Error " + NTRIM( e:osCode) + ");", pl := Zrodlo() + 'ERROR.LOG'
if ( e:genCode == EG_LOCK )
return ( .T. )
End
[...]
If NtoS( e:genCode) $ '345'
// by default, division by zero yields zero
If !www .and. ( tdz == Nil .OR. ElapTime( tdz, Time()) > '00:03:00')
Stop( StrTran( cMessage, ';', EOL), { || KodKlaw( 2, 13)}, 'W+/R', "╔═╗║╝═╚║ ")
tdz := Time()
End
Return If( e:genCode == 5, 0, .f.)
End
// obsluga po stronie przegladarki !
if www ; break( e)
end
aOptions := {"Omin", "Koniec"} // her begining build skip, quit, ignore etc. to alert
Regards,
Od: marek.h...@interia.pl
Do: harbou...@googlegroups.com;
Wysłane: 4:00 Sobota 2013-10-26
Temat: Re: [harbour] mongoose embedded web server + harbour interpreter, why not ?
[...]
switch to something better. But I would advise you to change ".bos" to ".hb" and run here scripts like hbmk2, written in harbour, using \harbour\contrib\hbrun\. In hbmk2.prg in line 1606 you can see using examle : hb_run( LaunchCommand( tmp1 ) )
It's a mistake. Hb_run run command from operating systems. I meant, of course, about hb_hrbDo( hb_hrbLoad( 0xn, 'hbrFile.hrb')) or hb_hrbRun( 'hrbFile.hrb').
I do not use them, so I make mistakes.
Regards,
Marek Horodyski
Od: "Domenico D'Oria" <nikk...@gmail.com>
Do: harbou...@googlegroups.com;
Wysłane: 11:47 Czwartek 2013-10-24
Temat: Re: [harbour] mongoose embedded web server + harbour interpreter, why not ?
Hi homar
after a lot of time surf and search the web, i try to explain better my question.
i know there is webserver like hbttpd written in harbour, but the question is : can this good piece of software be able to "interprete" harbour as a scripting language, like php or for example lua ? or asp vbscript for the incoming standards like html5.
or we must use it as a programming language ? as showed in the examples.
best regards
Hi Domenico,
Whether you're on trial for serving web pages?
Harbour does not cease to amaze me. Look what I found in a file \harbour\contrib\hbhttpd\core.prg :
...
1631│STATIC FUNCTION compile_file( cFileName, hConfig )
1632│
1633│ LOCAL nPos, cTpl, aCode := {}
1634│
1635│ IF cFileName == NIL
1636│ cFileName := MEMVAR->server[ "SCRIPT_NAME" ]
1637│ ENDIF
1638│ cFileName := UOsFileName( hb_DirBase() + "tpl/" + cFileName + ".tpl" )
1639│ IF hb_FileExists( cFileName )
1640│ cTpl := hb_MemoRead( cFileName )
1641│ BEGIN SEQUENCE
1642│ IF ( nPos := compile_buffer( cTpl, 1, aCode ) ) < Len( cTpl ) + 1
1643│ Break( nPos )
1644│ ENDIF
1645│ RECOVER USING nPos
...