Web Server Written in Free Pascal?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Web Server Written in Free Pascal?

Anthony Walter-3
I've been tutoring kids on programming and using Free Pascal as their first computer language. I've been creating example programs to demonstrate different things computer can do and how certain technologies.

In that endeavor I've written a basic multi threaded web server as a command line application. I wanted to know if other people have done this much and it would be worthwhile for me to write up a small page with some example extensions to the web server. What is your opinion, are of this type of web server implementation and if there would be any value dedicating some time to writing up a page about it with more information.

The basic web server program which you can extend looks like this (optional clii switches include -port and binding -address):

{ A simple web server application }
program WebServer;

{$mode delphi}

uses
  WebServer.Tools;

{ This is our web handler for the web server }
procedure WebHandler(Request: TWebRequest; Response: TWebResponse);
begin
  { Try to send the requested resource }
  if not Response.SendFile(Request.Path) then
  begin
    { If it's not found return a 404 page }
    Response.Status := 404;
      Response.SendFile('/404');
  end;
  { Optionally print the request }
  if OptionVerbose then
      Request.Print;
end;

begin
  { Run the web server }
  WebServerRun(WebHandler);
end.

And objects to work upon the customizing your server look like this:

{ The TWebRequest class represents an http request }
type
  TWebRequest = class
  private
    procedure Parse(const Request: string);
  public
    { The raw request text sent by the client web browser }
    Raw: string;
    { Method which is usually GET or POST }
    Verb: string;
    { Path to the resource requested }
    Path: string;
    { Optional raw query string }
    Query: string;
    { Header name value pairs parsed into a handy collection }
    Headers: TNamedStrings;
    { Query or form parameter name value pairs parsed into a handy collection }
    Params: TNamedStrings;
    { Print out all the information related to the request }
    procedure Print;
  end;   


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Web Server Written in Free Pascal?

Michael Van Canneyt


On Wed, 27 Mar 2019, Anthony Walter wrote:

> I've been tutoring kids on programming and using Free Pascal as their first
> computer language. I've been creating example programs to demonstrate
> different things computer can do and how certain technologies.
>
> In that endeavor I've written a basic multi threaded web server as a
> command line application. I wanted to know if other people have done this
> much and it would be worthwhile for me to write up a small page with some
> example extensions to the web server. What is your opinion, are of this
> type of web server implementation and if there would be any value
> dedicating some time to writing up a page about it with more information.

>
> The basic web server program which you can extend looks like this (optional
> clii switches include -port and binding -address):

Ehm.
Have you ever checked out fpWeb  ? This exists since many years, distributed
by default in FPC.  The trunk version even supports SSL.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Web Server Written in Free Pascal?

Anthony Walter-3
No I haven't. I will check it out thank you. I just thought my implementation and interface was rather clean, simple, and easy to understand.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Web Server Written in Free Pascal?

Michael Van Canneyt


On Wed, 27 Mar 2019, Anthony Walter wrote:

> No I haven't. I will check it out thank you. I just thought my
> implementation and interface was rather clean, simple, and easy to
> understand.

I hope you'll be pleasantly surprised by the multitude of webprogramming
tools available in FPC. This is an area of very active development, the
latest addition is a complete REST bridge for SQLDB.

You may also want to check out the brook framework by Silvio Clecio and
WST if you need to create webservices.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Web Server Written in Free Pascal?

Anthony Walter-3
Okay, I will. Thank you.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Web Server Written in Free Pascal?

Dennis
In reply to this post by Michael Van Canneyt


Michael Van Canneyt wrote:

>
>
> On Wed, 27 Mar 2019, Anthony Walter wrote:
>
>> No I haven't. I will check it out thank you. I just thought my
>> implementation and interface was rather clean, simple, and easy to
>> understand.
>
> I hope you'll be pleasantly surprised by the multitude of webprogramming
> tools available in FPC. This is an area of very active development, the
> latest addition is a complete REST bridge for SQLDB.
>

Can you share the link of REST bridge for SQLDB?

Dennis
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Web Server Written in Free Pascal?

Michael Van Canneyt


On Mon, 1 Apr 2019, Dennis wrote:

>
>
> Michael Van Canneyt wrote:
>>
>>
>> On Wed, 27 Mar 2019, Anthony Walter wrote:
>>
>>> No I haven't. I will check it out thank you. I just thought my
>>> implementation and interface was rather clean, simple, and easy to
>>> understand.
>>
>> I hope you'll be pleasantly surprised by the multitude of webprogramming
>> tools available in FPC. This is an area of very active development, the
>> latest addition is a complete REST bridge for SQLDB.
>>
>
> Can you share the link of REST bridge for SQLDB?

Sure:

http://wiki.freepascal.org/SQLDBRestBridge

Today I made an integration with TMS Web core, so you can access it even
from Delphi in multiple ways :)

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal