Sign in Join

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

Mailing lists / fpc-pascal / 2010-07

fpweb tutorial

18 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Felipe Monteiro de Carvalho

Hello,

Does anyone know where I can find documentation or a tutorial about fpweb?

Also, is the version included in FPC 2.4.0 very old and I should really use the FPC SVN code or can I use the units that come with FPC 2.4.0?

I want to make a simple page which converts hexadecimal to a string. I found some, but they were really crappy. Plain CGI should be the prefered format, as apache modules are too much for this simple task.

thanks,

Felipe Monteiro de Carvalho

Reply by email

Luiz Americo Pereira Camara
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
Hello, Does anyone know where I can find documentation or a tutorial about fpweb?

http://blog.silvioprog.com.br/2010/06/criando-um-aplicativo-cgi-com_27.html

It's in portuguese

Luiz

Show quoted text 10 lines
Also, is the version included in FPC 2.4.0 very old and I should really use the FPC SVN code or can I use the units that come with FPC 2.4.0? I want to make a simple page which converts hexadecimal to a string. I found some, but they were really crappy. Plain CGI should be the prefered format, as apache modules are too much for this simple task. thanks,

Reply by email

Felipe Monteiro de Carvalho
to Luiz Americo Pereira Camara

Hello,

Thanks, with this blog I seam to be going somewhere and it worked ok with fpc 2.4.0 and the weblaz.lpk package.

One thing still: Is there support for templates?

I am doing something like this to load my page:

procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;
  AResponse: TResponse; var Handled: Boolean);
begin
  AResponse.ContentType := 'text/html;charset=utf-8';
  AResponse.Contents.LoadFromFile(ExtractFilePath(ParamStr(0)) +
'mainpage.html');
  Handled := True;
end;

Something like powutils templates would be extremely handy ... all that html mixed with pascal doesn't look very nice.

Felipe Monteiro de Carvalho

Reply by email

Michael Van Canneyt
to Felipe Monteiro de Carvalho: Thanks, with this blog I seam to be going somewhere and it worked ok with fpc 2.4.0 and…
Felipe Monteiro de Carvalho wrote 20 lines
Hello, Thanks, with this blog I seam to be going somewhere and it worked ok with fpc 2.4.0 and the weblaz.lpk package. One thing still: Is there support for templates? I am doing something like this to load my page: procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: Boolean); begin AResponse.ContentType := 'text/html;charset=utf-8'; AResponse.Contents.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'mainpage.html'); Handled := True; end; Something like powutils templates would be extremely handy ... all that html mixed with pascal doesn't look very nice.

You have templates, if you use actions.

Just create an action, and assign a template to it.

Michael.

Reply by email

Michael Van Canneyt
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 6 lines
On Tue, Jul 13, 2010 at 5:10 PM, Michael Van Canneyt wrote: > Well, Request.Variables['Myvar'] is enough, no ? Doesn't seam to exist in fpc 2.4.0, any idea how to do that with that version? I found a couple of stuff which didn't work, including:

My mistake, the correct name is 'Queryfields':

Avar:=Request.QueryFields['MyVar'];

And fieldByName() exists already in 2.2, but that queries environment variables, not query variables (hence it will get stuff like 'QUERY_STRING').

I've never heard of GetParam()

Michael.

Reply by email

Felipe Monteiro de Carvalho
to Michael Van Canneyt
Michael Van Canneyt wrote
My mistake, the correct name is 'Queryfields': Avar:=Request.QueryFields['MyVar'];

Well, that takes an integer as argument, not a string, but I managed to build my own routine for that. If something like that isn't already in svn fpweb then it should probably be added:

function TFPWebModule1.GetQueryFieldByName(ARequest: TRequest; AName:
string): string;
var
  i, StrIndex: Integer;
  Str: string;
begin
  for i := 0 to ARequest.QueryFields.Count - 1 do
  begin
    StrIndex := Pos('=', ARequest.QueryFields[i]);
    Str := ARequest.QueryFields[i];
    if Copy(Str, 1, StrIndex - 1) = AName then
    begin
      Result := Copy(Str, StrIndex + 1, Length(Str) - StrIndex);
      Break;
    end;
  end;
end;
Felipe Monteiro de Carvalho

Reply by email

Michael Van Canneyt
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 9 lines
On Tue, Jul 13, 2010 at 5:20 PM, Michael Van Canneyt wrote: > My mistake, the correct name is 'Queryfields': > > Avar:=Request.QueryFields['MyVar']; Well, that takes an integer as argument, not a string, but I managed to build my own routine for that. If something like that isn't already in svn fpweb then it should probably be added:

Not needed, it is a regular stringlist, I again typed a mistake. (I should not do 2 things at the same time :/)

AVar:=Request.QueryFields.Values['MyVar'];

Sorry about the confusion.

But maybe a GetQueryVar() would not be a bad idea.

Michael.

Reply by email

Felipe Monteiro de Carvalho
to Michael Van Canneyt

By the way, is there a page in the wiki about fpweb? I used the wiki search and found none. I would like to add this info to the wiki, but thought about asking if there is already a page about it (the wiki search isn't very reliable).

thanks,

Felipe Monteiro de Carvalho

Reply by email

ABorka
to Felipe Monteiro de Carvalho: Thanks, with this blog I seam to be going somewhere and it worked ok with fpc 2.4.0 and…

/lazarus/components/fpweb/demo/fptemplate/*.*

has examples of how to use templates and template tags.

Felipe Monteiro de Carvalho wrote 21 lines
Hello, Thanks, with this blog I seam to be going somewhere and it worked ok with fpc 2.4.0 and the weblaz.lpk package. One thing still: Is there support for templates? I am doing something like this to load my page: procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: Boolean); begin AResponse.ContentType := 'text/html;charset=utf-8'; AResponse.Contents.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'mainpage.html'); Handled := True; end; Something like powutils templates would be extremely handy ... all that html mixed with pascal doesn't look very nice.

Reply by email

Michael Van Canneyt
to Felipe Monteiro de Carvalho: By the way, is there a page in the wiki about fpweb? I used the wiki search and found…
Felipe Monteiro de Carvalho wrote
By the way, is there a page in the wiki about fpweb? I used the wiki search and found none. I would like to add this info to the wiki, but thought about asking if there is already a page about it (the wiki search isn't very reliable).

look for fcl-web, but the page is very limited :-)

Michael.

Reply by email

Michael Van Canneyt
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 5 lines
I added a small introduction here: http://wiki.lazarus.freepascal.org/fcl-web Having said that, I think that fpWeb worked quite well for my very simple web page and all kinds of web applications could be developed with it.

Great work.

I have expanded the page with some explanations on multiple modules and actions.

Some things that need more work:
- Templates
- Content producers
- Difference between HTML Web module and regular web module

Michael.

Reply by email

ABorka
to Michael Van Canneyt: Great work. I have expanded the page with some explanations on multiple modules and…

I've added some words on templates that points to the readme files and the example projects now coming with Lazarus demonstrating the usage of templates.

AB

Michael Van Canneyt wrote 27 lines
On Fri, 16 Jul 2010, Felipe Monteiro de Carvalho wrote: > I added a small introduction here: > http://wiki.lazarus.freepascal.org/fcl-web > > Having said that, I think that fpWeb worked quite well for my very > simple web page and all kinds of web applications could be developed > with it. Great work. I have expanded the page with some explanations on multiple modules and actions. Some things that need more work: - Templates - Content producers - Difference between HTML Web module and regular web module Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email