Recent

Author Topic: [Tutorial] Basic fpWeb Tutorial Article  (Read 40311 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #30 on: December 21, 2016, 10:17:06 am »
I've changed the units "httpd" to "httpd24" and "fpapache" to "fpapache24" now the apache server starts well. But when the request reaches the server it doesn't responds. Checking the apache "error_log" file I read that the error that occurred is

Quote
    An unhandled exception occurred at $00007FF8F0760C66:
    EHTTP: No REQUEST_METHOD passed from server.
      $00007FF8F0760C66
Googling the message "No REQUEST_METHOD passed from server" points to FPC repositories only. For that reason I added temporary logs everywhere to pin point if there is something wrong with my code (which works fine on Apache 2.2) and the only logs I have are the ones in the "begin ... end." of the ".lpr" file. It makes me think that the exception is raised before my code has a chance to read the request.
Something within apache virtual server config, I believe. I don't know how apache pass environment variables to its modules, but the core of fcl-web expects at least that environment variable to work.

garlar27

  • Hero Member
  • *****
  • Posts: 652
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #31 on: December 21, 2016, 06:03:09 pm »
Well, things got more complicated than I anticipated. I will try to follow this problem in other thread.

Resume:
Changing the uses units "httpd" to "httpd24" and "fpapache" to "fpapache24" allow Apache server to start.

The problem I still have:
In case some one is interested will be explain in more detail in the following thread Problems with modules for APACHE 2.4

ozznixon

  • Full Member
  • ***
  • Posts: 119
    • http://www.modernpascal.com/
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #32 on: March 03, 2017, 05:17:11 pm »
Kudos - Great Start!
---
Want to kick the tires to a Free Pascal like script engine? http://www.ModernPascal.com/

ahiggins

  • Jr. Member
  • **
  • Posts: 92
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #33 on: March 03, 2017, 05:25:16 pm »
Thank you very much

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #34 on: March 24, 2017, 07:03:45 am »
I cannot see the tutorial.  It says something like:  "Dropbox - 404 cannot the file".

nummer8

  • Full Member
  • ***
  • Posts: 108
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #35 on: March 24, 2017, 08:54:18 am »
Try this link

https://bitbucket.org/leledumbo/books/downloads/

or use google
fpweb tutorial

Jos

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #36 on: March 24, 2017, 10:11:55 am »
Try this link

https://bitbucket.org/leledumbo/books/downloads/

or use google
fpweb tutorial

Jos

Thank you. Really appreciate.

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #37 on: March 24, 2017, 12:19:15 pm »
I did some tests myself, and I'd like to share what I have found with you, hoping that my experience help some guys at least. I tried to make my own web-server application in CGI way. The structure is rather similar with "WEBSNAP" in Delphi, which is deprecated now.  What I'd like to say is about action of event handlers. 

I put one module, let's say "mod1", and one action, let's say "act1" and set it as default.

If you call your app from browser, by typing in  "localhost/exec/mycgi.exe/act1" in the browser address windonw, it seems that event handlers run in following order:

- module_oncreate
- module_afterrequest
- module_beforerequest
- module_onrequest
- module_ongetaction

- action_beforerequest
- action_onrequest
- action_afterresponse

- module_afterresponse
- module_on destroy

This means you can process your data on the server side at any position here, except you set "handled := true" in moudle_onrequest procedure. This will make your application skip to "module_afterresponse".

Here, "processing" does not necessarily affect the HTML output, which client browser will actually see.  Basically you can change your output content directly, changing content of "AResponse.Contents" at module_onrequest, module_afterresponse, action_onrequest, action_afterresponse.

Let's see an example:

module_onrequest:
    AResponse.Contents.Add ('Hello, world <br />');
    Handled :=false;
action_onrequest:
   AResponse.Contents.Add('You called action <br />');
   Handled := true;     // if you comment this out, default serems handled = falset
action_afterresponse:
   AResponse.Contents.Add('Actions done<br />');
module_afterresponset:
    AResponse.Contents.Add ('I finished my response <br />');
 
Then you will see in our browser:

  Hello, world
  You called action
  Actions done
  I finished my response

If you set handled:=true in module_onrequest, then you would see:

  Hello, world

Setting "handled:= ture" does not operate in the same way in module and action. If you set handled true, the process in the module_afterresponse IS processed, but response contents defined there are not.

Another thing to mention is regarding defining "Contents" in action property --- you can directly type in the small editor box. Let's assume that you typed in "Contents from property Contents <br />" in Contents in act1's property. 

If you set handled := true in the action_onrequest, you will get the same result above (assuming handled := false in module_onrequest).

When you set handled to false in the action_onrequest, then you will get:
 
  Hello, world
  You called action
  Contents from property Contents
  Actions done
  I finished my response

With this, I think we can break down our application bit by bit, and process each part at different positions at our convenience.

Hope you can include this content in your tutorial if you think helpful. I spend rather long time to figure out this structure in the past, and want others who start webprogramming do not have to spend time here.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #38 on: March 25, 2017, 07:19:39 am »
Hope you can include this content in your tutorial if you think helpful. I spend rather long time to figure out this structure in the past, and want others who start webprogramming do not have to spend time here.
Feel free to submit a pull request. Although I'm a bit unsure whether such a deep flow explanation is necessary for basic tutorial. Moreover, recently it gets new simpler and a lot more flexible routing mechanism. I have no idea where to insert it in the existing sections.

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #39 on: March 26, 2017, 11:21:50 am »
Feel free to submit a pull request. Although I'm a bit unsure whether such a deep flow explanation is necessary for basic tutorial. Moreover, recently it gets new simpler and a lot more flexible routing mechanism. I have no idea where to insert it in the existing sections.

You are right. there are many other ways of routing. This may be useful only when setting "handled" is the most convenient way of controlling  flow. I just wanted to make it easier to understand the role of setting 'handled" true or false.

juliano

  • Newbie
  • Posts: 1
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #40 on: May 26, 2017, 03:06:50 am »
Hello Leledumbo, do you have any brook framework tutorial?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #41 on: May 26, 2017, 07:00:37 am »
Hello Leledumbo, do you have any brook framework tutorial?
In my head, not yet dumped to books.


Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #43 on: June 03, 2018, 11:14:13 pm »
My tutorial has been updated tocover the new routing mechanism. The PDF has been generated from Typora instead of ReText and internal links are now working. To avoid confusion, old downloads have been removed.

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Re: [Tutorial] Basic fpWeb Tutorial Article
« Reply #44 on: June 08, 2018, 05:18:56 am »
Wow really great. Really appreciate your efforts. Downloading from dropbox does not work.
So I downloaded from

https://bitbucket.org/leledumbo/books/downloads/

 

TinyPortal © 2005-2018