fpweb/weblaz questions.
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
BSaidus · 2023-04-11 09:35
Hello,
Excuse my ignorance gays and try to be patient with me .
I have some questions about using weblz/fpweb as an alternative to
PHP, so I appreciate some help (answers) from you.
1. Can I use weblz/fpweb as cgi in replacement to PHP ?
2. Having html, css, js, images (png, jpg) files all ready, Can I
deserve them using cgi module ( for lighttpd http server )?
My scenario is, I have my application running in php & I want to
convert it in fpc, the application consiste in ONE php(html)file that
contain web form and css and js files attached to it, and after each
sending data from the form, the php saves that data in json file, and
when returning I display that data in the html form again.
In php I just call a function that I made to read the json file into
an array then when the browser return after saving, I call this
function and I assignes values to edit(s) via.
Code: PHP [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i "/>
so How to integrate that mechanism using fpweb/weblaz ??
Thank you.
----------------------------------------------------------------------
domasz · 2023-04-11 10:12
https://wiki.freepascal.org/fpWeb_Tutorial
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i Value:
String...with AResponse.Contents do beginAdd('');
or use some templating system. In PHP there is Smarty. In Smarty you
write code like this:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
Then in Lazarus you can use such files quite easily.
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i L:
TStringList;Vars: TStringList; Vars :=
TStringList.Create;Vars.Add('Var1=Value1');Vars.Add('Var2=Value2'); L
:= TStringList.Create;L.LoadFromFile('template.htm');for i:=0 to
Vars.Count-1 do begin Name := Vars.Names[i]; Value :=
Vars.Values[i]; L.Text := StringReplace('{' + Name +'}', Value,
[rfReplaceAll]);end;
----------------------------------------------------------------------
BSaidus · 2023-04-11 11:07
Thanks,
But how about other files ( *.js, *.css, *.png, ... ).
In the handler, I do not think that I should send every file content
separatelly
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i procedure
TUfpweb.DataModuleRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);begin Handled := true;
AResponse.Contents.LoadFromFile('index.html');end;
In the scenario of lighttpd, php, I just call
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
/host/index.php and all associated with this resource (index.php) will
be downloaded by the briwser.
----------------------------------------------------------------------
domasz · 2023-04-11 11:38
As far as I know fpWeb is a replacement for PHP and
lighttpd/Apache/nginx. So you need to reimplement what PHP does and
what the www server does.
----------------------------------------------------------------------
Leledumbo · 2023-04-11 12:28
Quote from: BSaidus on April 11, 2023, 11:35:03 amCan I use
weblz/fpweb as cgi in replacement to PHP ?
Yes
Quote from: BSaidus on April 11, 2023, 11:35:03 amHaving html, css,
js, images (png, jpg) files all ready, Can I deserve them using cgi
module ( for lighttpd http server )?
Yes, but you shouldn't. Delegate that to a dedicated web server
instead. If you insist, see this paragraph from tips and tricks
section of my above tutorial.
Quote from: BSaidus on April 11, 2023, 11:35:03 amHow to integrate
that mechanism using fpweb/weblaz ??
Again, from the same tutorial on different section. I don't really
suggest using FPTemplate since it's kinda ancient and not really
convenient. FPC has fcl-mustache package documented here (I guess?),
this one is better IMO.
----------------------------------------------------------------------
BSaidus · 2023-04-11 18:25
Thank you for help & information.
I'll try and see.
----------------------------------------------------------------------
BSaidus · 2023-04-14 07:42
I constat that fcl-mustache do not come for fpc3.2.2
----------------------------------------------------------------------
Leledumbo · 2023-04-14 10:21
Quote from: BSaidus on April 14, 2023, 09:42:31 amI constat that fcl-
mustache do not come for fpc3.2.2
Yes, it's a little bit too late. 3.2.2 was released on May 2021, which
already has feature frozen a couple of months before. The first commit
to fcl-mustache happend in April 2021. However, the package itself
compiles fine with 3.2.2, so if you have to stick with it, you can
just grab the folder or even just the unit (only fpmustache.pas
matters, unless you need the expression parser / dataset extension).
----------------------------------------------------------------------
BSaidus · 2023-04-14 16:37
thanks @Leledumbo
----------------------------------------------------------------------
BSaidus · 2023-04-14 20:51
Please help.
Given this json data
Code: Javascript [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i {
"host":{ "name" : "uc1.uccenos.net", "ip" :
"123.33.32.1", "mask" : "222.222.222.0", "gateway" :
"123.33.23.3" }} and this template with expression
Code: Text [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i