#1 2015-11-08 14:18:04

jik
Member
Registered: 2015-11-02
Posts: 4

A CGI application example using mORMot

Hi All,
I am new to mORMot and I have a lot a small Object Pascal command line applications I developed over the years and normally use for my job. Now, as I discovered mORMot, I think it is a good idea to use them as CGI applications using this wonderful framework, so I wonder if there is already a small example about how to use CGI apps with mORMot, or at least some hints. Thank you.

Offline

#2 2015-11-08 14:57:52

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: A CGI application example using mORMot

Please, take a look at mORMotFastCgiServer.pas. Some usage tips are inside.

Offline

#3 2015-11-09 07:44:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: A CGI application example using mORMot

I do not understand how CGI may help...

Why not just call the external command line applications from a mORMot interface-based server, or - even better - reuse the small Object Pascal command line applications within a mORMot interface-based server directly?

Offline

#4 2015-11-10 13:12:11

jik
Member
Registered: 2015-11-02
Posts: 4

Re: A CGI application example using mORMot

ab wrote:

I do not understand how CGI may help...

reuse the small Object Pascal command line applications within a mORMot interface-based server directly?

Could you please give me a small example, or just a hint, seen I am very new to mORMot. Given I have myapp.exe...
Thank you.

Offline

#5 2015-11-10 14:17:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: A CGI application example using mORMot

It would depend on what is within your myapp.exe, and how the input parameters are defined...

Offline

#6 2015-11-10 17:16:42

jik
Member
Registered: 2015-11-02
Posts: 4

Re: A CGI application example using mORMot

Well, with the good old xitami web server I did something like this:
program summing;
{$APPTYPE CONSOLE}
uses
  SysUtils, cgi;

var
  x, y, z: double;
  tempStr: string;

function sum(a, b: double): double;
begin
  result := a+b;
end;

function FormFloat(s: string): double;
begin
// read the name and the value of the input data from a HTML form sent by the browser
// and return the value as a double
end;

begin
  x := FormFloat('name1');
  y := FormFloat('name2');
  z := x+y;
  tempStr := FloatToStr(z);
  // send the data to the browser
  writeln(tempStr);
end.
What I want is to do is, more or less, something like this using mORMot.
Seen mORMot is huge, what are the important parts to learn first to write this kind of applications? Thank you.

Offline

#7 2015-11-10 17:38:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: A CGI application example using mORMot

For writing standard web/REST operations, I guess you may just try to define some method-based services.
See http://synopse.info/files/html/Synopse% … DE_TITL_49
and https://github.com/synopse/mORMot/tree/ … %20Service

As an alternative, especially if you want to have Delphi clients or AJAX clients, you may try interface-based services.
See http://synopse.info/files/html/Synopse% … ml#TITL_63
and https://github.com/synopse/mORMot/tree/ … 20services

Take also a look at https://tamingthemormot.wordpress.com/

Offline

Board footer

Powered by FluxBB