Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-05

fpWeb & fcgi

11 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Lee Jenkins

I have a web type project coming up and decided to poke around in the fpWeb stuff. My, you guys have been busy, I never took a good look around the fpweb/laz web sources till today. I was thinking of using php with symfony or one of the smaller frameworks, but its a bit overkill for my project. I'm considering using fpweb/lazarus so I'm writing a small test application.

I thought I saw mention of a embedded web server available? I currently have a pretty simple embedded server using synapse that is a modified version of the demo that comes with the sources. I was thinking of writing a TCustomWebApplication to use that. But I did remember somewhere in a recent thread, there was mention of an existing embedded server...?

Also, if its not too much trouble, a sample of someone's <IfModule mod_fastcgi.c> declaration, etc for httpd.conf, I'd appreciate it. I'm looking at samples on the web now for setting up apache for fcgi, but most of its for php fcgi setup and I'm trying to get my head around setting apache to look for fpweb fcgi apps to handle requests.

What I'd like to do is work through the process of writing a small sample app (easy peasy) and then setting up the environment to start testing right away so if I ask a lot elementary questions...

I'll be documenting the creation of a small web app that will be using some of the basic stuff in fpweb like templates, sending xml/json, using content producers, etc including setting up for the different host environments like apache vs fcgi, etc. I'll put it on the wiki or submit it over the tracker when I'm finished.

Thanks,

Warm Regards, Lee

Reply by email

ABorka
to Lee Jenkins
Lee Jenkins wrote 37 lines
I have a web type project coming up and decided to poke around in the fpWeb stuff. My, you guys have been busy, I never took a good look around the fpweb/laz web sources till today. I was thinking of using php with symfony or one of the smaller frameworks, but its a bit overkill for my project. I'm considering using fpweb/lazarus so I'm writing a small test application. I thought I saw mention of a embedded web server available? I currently have a pretty simple embedded server using synapse that is a modified version of the demo that comes with the sources. I was thinking of writing a TCustomWebApplication to use that. But I did remember somewhere in a recent thread, there was mention of an existing embedded server...? Also, if its not too much trouble, a sample of someone's <IfModule mod_fastcgi.c> declaration, etc for httpd.conf, I'd appreciate it. I'm looking at samples on the web now for setting up apache for fcgi, but most of its for php fcgi setup and I'm trying to get my head around setting apache to look for fpweb fcgi apps to handle requests. What I'd like to do is work through the process of writing a small sample app (easy peasy) and then setting up the environment to start testing right away so if I ask a lot elementary questions... I'll be documenting the creation of a small web app that will be using some of the basic stuff in fpweb like templates, sending xml/json, using content producers, etc including setting up for the different host environments like apache vs fcgi, etc. I'll put it on the wiki or submit it over the tracker when I'm finished. Thanks, -- Warm Regards, Lee

http://www.lazarus.freepascal.org/index.php/topic,12817.msg66447.html#msg66447

has some info on the apache FCGI config.
Use FPC and Lazarus from the latest SVN sources to get the latest updates and fixes.
(note, that currently Apache modules are not compiling properly /no errors, only the modules does not work/, so only use CGI or FCGI).

AB

Reply by email

Joost van der Sluis
to Lee Jenkins: I have a web type project coming up and decided to poke around in the fpWeb stuff. My,…
Lee Jenkins wrote 11 lines
I have a web type project coming up and decided to poke around in the fpWeb stuff. My, you guys have been busy, I never took a good look around the fpweb/laz web sources till today. I was thinking of using php with symfony or one of the smaller frameworks, but its a bit overkill for my project. I'm considering using fpweb/lazarus so I'm writing a small test application. I thought I saw mention of a embedded web server available? I currently have a pretty simple embedded server using synapse that is a modified version of the demo that comes with the sources. I was thinking of writing a TCustomWebApplication to use that. But I did remember somewhere in a recent thread, there was mention of an existing embedded server...?

fppkg update
fppkg install embweb
restart Lazarus
In Lazarus->install packages-> select embweb-> install

Then create a new 'web application'. If you add the define 'FCGI' it will be fastcgi, if you define 'CGI' if will be a cgi-application. If you do not define anything, you can just run the application and connect on port 7004.

Note that you need a working fppkg configuration. But in most cases it will work out-of-the-box. You probably only have to set the path to your Lazarus installation:
http://wiki.freepascal.org/fppkg#Configuration_for_use_with_Lazarus

Joost.

Reply by email

Marcos Douglas
to Joost van der Sluis
Joost van der Sluis wrote 27 lines
On Sun, 2011-05-08 at 23:41 -0400, Lee Jenkins wrote: > I have a web type project coming up and decided to poke around in the fpWeb > stuff. ?My, you guys have been busy, I never took a good look around the > fpweb/laz web sources till today. ?I was thinking of using php with symfony or > one of the smaller frameworks, but its a bit overkill for my project. ?I'm > considering using fpweb/lazarus so I'm writing a small test application. > > I thought I saw mention of a embedded web server available? ?I currently have a > pretty simple embedded server using synapse that is a modified version of the > demo that comes with the sources. ?I was thinking of writing a > TCustomWebApplication to use that. ?But I did remember somewhere in a recent > thread, there was mention of an existing embedded server...? fppkg update fppkg install embweb restart Lazarus In Lazarus->install packages-> select embweb-> install Then create a new 'web application'. If you add the define 'FCGI' it will be fastcgi, if you define 'CGI' if will be a cgi-application. If you do not define anything, you can just run the application and connect on port 7004. Note that you need a working fppkg configuration. But in most cases it will work out-of-the-box. You probably only have to set the path to your Lazarus installation: http://wiki.freepascal.org/fppkg#Configuration_for_use_with_Lazarus

Everything this works only in FPC 2.5.1?

Marcos Douglas

Reply by email

Joost van der Sluis
to Marcos Douglas
Marcos Douglas wrote 30 lines
On Mon, May 9, 2011 at 7:48 AM, Joost van der Sluis wrote: > On Sun, 2011-05-08 at 23:41 -0400, Lee Jenkins wrote: >> I have a web type project coming up and decided to poke around in the fpWeb >> stuff. My, you guys have been busy, I never took a good look around the >> fpweb/laz web sources till today. I was thinking of using php with symfony or >> one of the smaller frameworks, but its a bit overkill for my project. I'm >> considering using fpweb/lazarus so I'm writing a small test application. >> >> I thought I saw mention of a embedded web server available? I currently have a >> pretty simple embedded server using synapse that is a modified version of the >> demo that comes with the sources. I was thinking of writing a >> TCustomWebApplication to use that. But I did remember somewhere in a recent >> thread, there was mention of an existing embedded server...? > > fppkg update > fppkg install embweb > restart Lazarus > In Lazarus->install packages-> select embweb-> install > > Then create a new 'web application'. If you add the define 'FCGI' it > will be fastcgi, if you define 'CGI' if will be a cgi-application. If > you do not define anything, you can just run the application and connect > on port 7004. > > Note that you need a working fppkg configuration. But in most cases it > will work out-of-the-box. You probably only have to set the path to your > Lazarus installation: > http://wiki.freepascal.org/fppkg#Configuration_for_use_with_Lazarus Everything this works only in FPC 2.5.1?

Or 2.4.4 when it's released. But you can also get this to work with 2.4.2. But there have been a lot of fcl-web related fixes since then, so I won't advise spend time on that.

Joost.

Reply by email

Lee Jenkins
to Joost van der Sluis: fppkg update fppkg install embweb restart Lazarus In Lazarus->install packages-> select…
Joost van der Sluis wrote 18 lines
On Sun, 2011-05-08 at 23:41 -0400, Lee Jenkins wrote: > I have a web type project coming up and decided to poke around in the fpWeb > stuff. My, you guys have been busy, I never took a good look around the > fpweb/laz web sources till today. I was thinking of using php with symfony or > one of the smaller frameworks, but its a bit overkill for my project. I'm > considering using fpweb/lazarus so I'm writing a small test application. > > I thought I saw mention of a embedded web server available? I currently have a > pretty simple embedded server using synapse that is a modified version of the > demo that comes with the sources. I was thinking of writing a > TCustomWebApplication to use that. But I did remember somewhere in a recent > thread, there was mention of an existing embedded server...? fppkg update fppkg install embweb restart Lazarus In Lazarus->install packages-> select embweb-> install

I tried that with the latest snapshot and it spat out an AV. I guess the FPC 2.4.3 doesn't work for that?

The problem is that I'm on Windows and its such a bear to setup Lazarus/FPC to compile from sources, at least in my limited experience in doing it.

What I'd really like to do anyway is write a TCustomWebApplication descendant for the Synapse server I've been using for a while now. It also supports HTTPS with openssl which is a nice bonus for the application that I have in to write since it needs to be stand alone with the possibility of scaling up to use apache mod or fastcgi for larger installations.

I've been studying custfcgi and fpapache units to see how they are written and it seems pretty straight forward though I have a couple of questions. First, the basic logic is pretty easy to follow. The TCustomWebApplication is the basic application object that is used and is composed with a TWebHandler descendant which is instantiated through .InitializeWebHandler and does most of the work of communicating with the client process, creating the TRequest and TResponse object to be pass to the appropriate TfpWebModule.

1. TWebHandler.GetApplicationURL.
I assume this is the base url root directory from the perspective of the client. www.google.com would be the base url for instance.

2. TWebHandler.WaitForRequest vs. TWebHandler.HandleRequest. Judging from the source in both custfcgi and fpapache units, it looks like they are optional to use one or the other? TApacheHandler uses a dummy/fall through method for WaitForRequest and instead implements logic in .HandleRequest. TFCGIHandler on the other hand, uses WaitForRequest and implements logic there while not implementing .HandleRequest one would be most optimal to use? It looks to me that for a synapse server like I have, .WaitForRequest would be the choice here?

3. Handling TRequest and TResponse objects.

3a) I may be hitting a brain fart here, but who is responsible for destroying the TRequest and TResponse objects?

3b) What is the format for populating TRequest object with variables like get vars, http headers, etc? I've been looking around the source, and I haven't yet found where this is happening :-)

4) What is the protocol for using a restful type url like this?

http://mysite.com/module-name/function-name/var1/var2/var3

5) For those instances where I need to build a page or fragment of html through code, which unit is recommended? There seems to be some overlap between fcl-xml/dom_html.pp and fcl-xml/htmlelements.pp.

More questions to come I'm sure, but in the meantime, any help is as always, appreciated.

Warm Regards, Lee

Reply by email

Joost van der Sluis
to Lee Jenkins
Lee Jenkins wrote 22 lines
On 5/9/2011 6:48 AM, Joost van der Sluis wrote: > On Sun, 2011-05-08 at 23:41 -0400, Lee Jenkins wrote: >> I have a web type project coming up and decided to poke around in the fpWeb >> stuff. My, you guys have been busy, I never took a good look around the >> fpweb/laz web sources till today. I was thinking of using php with symfony or >> one of the smaller frameworks, but its a bit overkill for my project. I'm >> considering using fpweb/lazarus so I'm writing a small test application. >> >> I thought I saw mention of a embedded web server available? I currently have a >> pretty simple embedded server using synapse that is a modified version of the >> demo that comes with the sources. I was thinking of writing a >> TCustomWebApplication to use that. But I did remember somewhere in a recent >> thread, there was mention of an existing embedded server...? > > fppkg update > fppkg install embweb > restart Lazarus > In Lazarus->install packages-> select embweb-> install > I tried that with the latest snapshot and it spat out an AV. I guess the FPC 2.4.3 doesn't work for that?

On which command? It's possible to get this working on fpc 2.4.3, but I won't bother.

The problem is that I'm on Windows and its such a bear to setup Lazarus/FPC to compile from sources, at least in my limited experience in doing it.

Just download a lazarus snapshot?

4) What is the protocol for using a restful type url like this? http://mysite.com/module-name/function-name/var1/var2/var3

You van use 'GetNexPath' to get the next 'parameter' in the URL.

5) For those instances where I need to build a page or fragment of html through code, which unit is recommended? There seems to be some overlap between fcl-xml/dom_html.pp and fcl-xml/htmlelements.pp.

I always use htmlelements and the htmlwriter.

Joost.

Reply by email

Lee Jenkins
to Joost van der Sluis
Joost van der Sluis wrote 26 lines
On Sat, 2011-05-14 at 13:13 -0400, Lee Jenkins wrote: > On 5/9/2011 6:48 AM, Joost van der Sluis wrote: >> On Sun, 2011-05-08 at 23:41 -0400, Lee Jenkins wrote: >>> I have a web type project coming up and decided to poke around in the fpWeb >>> stuff. My, you guys have been busy, I never took a good look around the >>> fpweb/laz web sources till today. I was thinking of using php with symfony or >>> one of the smaller frameworks, but its a bit overkill for my project. I'm >>> considering using fpweb/lazarus so I'm writing a small test application. >>> >>> I thought I saw mention of a embedded web server available? I currently have a >>> pretty simple embedded server using synapse that is a modified version of the >>> demo that comes with the sources. I was thinking of writing a >>> TCustomWebApplication to use that. But I did remember somewhere in a recent >>> thread, there was mention of an existing embedded server...? >> >> fppkg update >> fppkg install embweb >> restart Lazarus >> In Lazarus->install packages-> select embweb-> install >> > > I tried that with the latest snapshot and it spat out an AV. I guess the FPC > 2.4.3 doesn't work for that? On which command? It's possible to get this working on fpc 2.4.3, but I won't bother.

fppkg install embweb

When it didn't work the first time, I also tried fppkg download embweb before fppkg install embweb, but the result was the same.

Show quoted text 5 lines
> The problem is that I'm on Windows and its such a bear to setup Lazarus/FPC to > compile from sources, at least in my limited experience in doing it. Just download a lazarus snapshot?

Odd. That is what I did after your first reply to my original post. I downloaded and installed the latest snapshot "Lazarus + fpc 2.4.3" for Win32 from here: http://www.hu.freepascal.org/lazarus/

Show quoted text 12 lines
> 4) What is the protocol for using a restful type url like this? > > http://mysite.com/module-name/function-name/var1/var2/var3 You van use 'GetNexPath' to get the next 'parameter' in the URL. > 5) For those instances where I need to build a page or fragment of html through > code, which unit is recommended? There seems to be some overlap between > fcl-xml/dom_html.pp and fcl-xml/htmlelements.pp. I always use htmlelements and the htmlwriter.

OK. DOM_HTML looks pretty useful though. There seems to be some overlap in functionality of the two units (dom_html and htmlelements).

Thanks again!

Warm Regards, Lee

Reply by email

Michael Schnell
to Lee Jenkins: I tried that with the latest snapshot and it spat out an AV. I guess the FPC 2.4.3…
Lee Jenkins wrote
The problem is that I'm on Windows and its such a bear to setup Lazarus/FPC to compile from sources, at least in my limited experience in doing it.

I just did this with some help from the forum (see thread "Trying to get the svn versions of Lazarus and FPC running on Windows").

Works just fine right now. Try it and ask here if you get stuck.

-Michael

Reply by email

Mattias Gaertner
to Michael Schnell
Show quoted text 9 lines
On 05/14/2011 07:13 PM, Lee Jenkins wrote: > > The problem is that I'm on Windows and its such a bear to setup > Lazarus/FPC to compile from sources, at least in my limited experience > in doing it. I just did this with some help from the forum (see thread "Trying to get the svn versions of Lazarus and FPC running on Windows"). Works just fine right now. Try it and ask here if you get stuck.

Was the wiki page useful?
Can something be improved?

Mattias

Reply by email

Michael Schnell
to Mattias Gaertner
Mattias Gaertner wrote
Was the wiki page useful? Can something be improved?

I did not really do it completely along the lines of the Wiki page. but maybe I should have done this.

"Step #5" did help me greatly. I just needed to modify the file regarding that I forced the fpc install to "c:\fpc_2" instead of "c:\freepascal\fpc\2.5.1"( as recommended).

I do have a big issue each time I recompile fpc into an empty directory: fpc.cfg is not created.

When I after the installation, use fpcmkcfg, pointing it to an old fpc installation directory, the file is not usable and I need to manually change the paths according to the new installation directory.

Maybe here some improvement might be appropriate.

Thanks !
-Michael

Reply by email