Recent

Author Topic: Getting Started  (Read 7557 times)

acolburn

  • New Member
  • *
  • Posts: 14
Getting Started
« on: July 20, 2016, 05:17:06 pm »
I have a small app I wrote with FPC/Lazarus, trying hard to keep the GUI code separate from everything else. It cross compiles well on a PC and Mac. Now I'd like to try to make a web based version, still using Pascal.

 But I am an absolute newbie at this; I have self-studied Pascal for awhile and briefly explored PHP and Python for the web. I'm also OK with HTML/CSS. I have seen the fpWeb tutorial at the top of this thread, as well as Leledumbo's (2015) tutorial. They are both clear and bookmarked. However, I would be grateful for an even more basic tutorial.

Also, with Python and PHP it was pretty easy to just upload files to my web host; the interpreters were present, configured, and running. Are there any hosts doing the same thing for FPC or do I have to learn how to setup, configure, and run my own server?!

Thanks, as always -- Al


Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Getting Started
« Reply #1 on: July 20, 2016, 05:24:20 pm »
Al,

If you've kept the non-UI part of your program separate (ie, does not use any LCL units), you should be able to put that into a Pascal server app, or a Pascal dynamic library that can be used with a non-Pascal server app.

You might take a look at this. I've had good luck with this approach:

https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/WebAppOverview.html

As for a server, see Part 4 of this article series. It's not hard to set up a Windows or Linux server and the first year of AWS is free:

https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/PascalDynLibs.html

Feel free to ask questions about any of this. Quite a bit there.

-Phil

Leledumbo

  • Hero Member
  • *****
  • Posts: 8776
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Getting Started
« Reply #2 on: July 21, 2016, 02:53:25 am »
I have seen the fpWeb tutorial at the top of this thread, as well as Leledumbo's (2015) tutorial. They are both clear and bookmarked. However, I would be grateful for an even more basic tutorial.
Define "more basic". If it contradicts with the preface of my tutorial, sorry but no. I don't want to clutter it with basic HTTP protocol flow, specific web server configuration, etc. Their respective documentation is already huge enough.
Also, with Python and PHP it was pretty easy to just upload files to my web host; the interpreters were present, configured, and running. Are there any hosts doing the same thing for FPC or do I have to learn how to setup, configure, and run my own server?!
Depends on what protocol and how you want to deploy. CGI is typically just drop in (unless the web server doesn't support or is not configured to support, as many web hosting services do), FastCGI has several ways (manual separate instance maintenance to autospawning multiple instance), embedded server only needs proxy if you want to access it by name, apache module requires apache (for sure) and the ability to modify its configuration file.

acolburn

  • New Member
  • *
  • Posts: 14
Re: Getting Started
« Reply #3 on: July 21, 2016, 04:07:25 am »
My thanks to both of you for replying. Your text is clear Phil. As you say, there's quite a bit there. And, Leldumbo, I wasn't posting with the hope you would change your tutorial.  It's nice you did it at all, for free; I would never be critical. ... It's just difficult for me to find resources that fit my background. There's a gap between understanding variables and loops, basic OOP, etc. and the more advanced concepts needed for many real world applications, esp. if one likes Pascal:)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Getting Started
« Reply #4 on: July 21, 2016, 04:32:52 am »
I would suggest just getting a real server that you can install and configure as you want and start playing around with it. No better way to learn about this stuff. And you can't beat free.

To see how much you're saving and how much AWS would cost you after the first year, use Amazon's calculator:

https://calculator.s3.amazonaws.com/index.html

- Select a region. For example, US-East.

- Add an instance, then select a t2-micro with Windows or Linux. The t2-micro is free for 12 months.

- Add 30 GB of SSD storage. This is also free for 12 months.

I see $13.18/mo for Windows and $9.52/mo for Linux. But the total at the top should say $0.00 since this configuration qualifies for the free tier.

I use Windows since it works so well from my Mac via MS's Remote Desktop app. Like having Windows in a window on my desktop.

This is a pretty fast server too. Xeon E5-2670 @ 2.5 GHz. And the SSD storage really makes it go. You can even use this as a general-purpose machine. FPC and Lazarus work fine.

-Phil

bee

  • Sr. Member
  • ****
  • Posts: 393
Re: Getting Started
« Reply #5 on: July 24, 2016, 03:59:33 am »
Please be specific with your problem. Which is part that you don't understand, (1) the pascal code for web app or (2) how to write web app using fpweb or (3) how the web ecosystem works?

Writing a (CGI) web app using Pascal is actually very simple. It's not more complex than PHP's or Python's Hello World example. The minimum code should be like this:
Code: Pascal  [Select][+][-]
  1. program Hello;
  2.  
  3. begin
  4.   writeln('content-type: text/html;');
  5.   writeln;
  6.   writeln('Hello World from CGI!');
  7. end.

However, writing Hello World using fpWeb —or any web frameworks for that matter— is a bit complicated. But it's not really that hard either. My Hello World example is here (notice that the code can be run). More examples at the app's home path, including a file uploader.

If you need a server to play around, try to get a VPS so you could host and configure all the things you need with FPC web app development. There are many cheap VPS hosts out there, some even free for limited time.

Good luck! :)
« Last Edit: July 24, 2016, 04:01:07 am by bee »
-Bee-

A long time pascal lover.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Getting Started
« Reply #6 on: July 24, 2016, 04:11:53 am »
My Hello World example is here (notice that the code can be run).

I very much like your code viewer, but I still haven't seen anything done with fpWeb that's non-trivial in the UI department. For example, how difficult would it be to duplicate the general look, feel and functionality of this Fish Facts app, which can even be hosted on a Dropbox account?

https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/WebAppOverview.html

-Phil

bee

  • Sr. Member
  • ****
  • Posts: 393
Re: Getting Started
« Reply #7 on: July 24, 2016, 08:12:27 am »
I very much like your code viewer, but I still haven't seen anything done with fpWeb that's non-trivial in the UI department. For example, how difficult would it be to duplicate the general look, feel and functionality of this Fish Facts app, which can even be hosted on a Dropbox account?
https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/WebAppOverview.html

Your app is great, Phil.

Although in dynamic or complex web app, there are server side app and client/browser side app, a web app doesn't have to use both. As you've shown in your Fish Facts app, a web app can be a full browser side app, no server side app is needed. A collection of HTML, CSS, and JS files working together is sufficient for this kind of web app. Hence it can be hosted anywhere —even in a Dropbox account— because it doesn't have the server side part to be executed.

As we're Pascal programmer here, the web app we're talking about here is assumed to involve Pascal code. As Pascal code can't be run in the browser, it's obvious that Pascal code lies on the server side. As you've shown in your article above, having the server side and browser side separated is a good practice in web app development. I've learn this while ago when I was using ExtPascal. :) Though you may attach the client side code (the HTML, CSS, and JS) into the server side code, just like what I did in my example, it's actually not recommended. I did it just for the sake of simplicity. Especially at this time when the browser side is getting dynamic and complex as well, you will need to use either responsive or adaptive design for modern web app.

For serious (scalable medium to large) web app development, using each side's development techniques and technologies is highly recommended. Unless you got a one-stop solution for both server and browser side, such as Morfik. Although for small to medium scale web app, I think fpWeb's template engine is sufficient for the separation. Having the separation, you could manage the look, feel, and functionality of the browser side app whatever you want. You could build it using your own hard-coded solution, or you could use any browser side technologies available out there such as ExtJS, qooxdoo, boostrap, angular, react, etc … you pick it.

As long as there's no Pascal technology to handle the browser side part of a web app —the HTML, CSS, and JS— completely and comprehensively, we must learn those things. I see fpWeb is more targetted for server side tool. So, I think the look and feel of our (Pascal) web app isn't really within fpWeb's jobs.
-Bee-

A long time pascal lover.

bee

  • Sr. Member
  • ****
  • Posts: 393
Re: Getting Started
« Reply #8 on: July 24, 2016, 08:22:17 am »
By the way… Since my main concern on web app development is on the server side, I made WebCRT unit to ease simple web app development (on the server side), especially for newbies. Using this unit, creating a simple web app (using Pascal) can be as simple as writing console app. It may not look pretty, but it's pretty useful to make simple web app for prototyping or brainstorming. Here are the usage demo: wordpc.pas and xlscol.pas:D
-Bee-

A long time pascal lover.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Getting Started
« Reply #9 on: July 25, 2016, 04:10:46 am »
Although in dynamic or complex web app, there are server side app and client/browser side app, a web app doesn't have to use both. As you've shown in your Fish Facts app, a web app can be a full browser side app, no server side app is needed. A collection of HTML, CSS, and JS files working together is sufficient for this kind of web app. Hence it can be hosted anywhere —even in a Dropbox account— because it doesn't have the server side part to be executed.

Actually, even a Web app with a server side app can be hosted on Dropbox, just not the server side app. And of course the server side app would need to use https protocol, since that's what Dropbox accounts use.

You could build it using your own hard-coded solution, or you could use any browser side technologies available out there such as ExtJS, qooxdoo, boostrap, angular, react, etc … you pick it.

But I never see any fpWeb examples that actually _do_ this. Why don't you take the Fish Facts client app and put an fpWeb server app to it?

bee

  • Sr. Member
  • ****
  • Posts: 393
Re: Getting Started
« Reply #10 on: July 25, 2016, 04:52:09 am »
Actually, even a Web app with a server side app can be hosted on Dropbox, just not the server side app.
That's my whole point. *emphasize added by me:)

But I never see any fpWeb examples that actually _do_ this. Why don't you take the Fish Facts client app and put an fpWeb server app to it?
Why don't you? You simply need to change your server side Pascal code to use fpWeb to handle the request. Take a look at my fpWeb Hello World example above. ;)
-Bee-

A long time pascal lover.

Manlio

  • Full Member
  • ***
  • Posts: 164
  • Pascal dev
Re: Getting Started
« Reply #11 on: June 05, 2023, 02:44:35 pm »
Al,

If you've kept the non-UI part of your program separate (ie, does not use any LCL units), you should be able to put that into a Pascal server app, or a Pascal dynamic library that can be used with a non-Pascal server app.

You might take a look at this. I've had good luck with this approach:

https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/WebAppOverview.html

As for a server, see Part 4 of this article series. It's not hard to set up a Windows or Linux server and the first year of AWS is free:

https://dl.dropboxusercontent.com/u/28343282/MacXPlatform/PascalDynLibs.html

Feel free to ask questions about any of this. Quite a bit there.

-Phil

I'd like to study those articles about dynamic libraries, which I saw quoted in different places, but the dropbox link doesn't work any more, and I could not find them with google.

Does anyone have a copy or knows where they can be found?
manlio mazzon gmail

delphius

  • Jr. Member
  • **
  • Posts: 77
Re: Getting Started
« Reply #12 on: June 05, 2023, 08:58:08 pm »
fpmtls - ssl/tls 1.3 implementation in pure pascal
fpmailsend - sending a simple email message
pascal-webui - use web browser as gui and fpc as backend

 

TinyPortal © 2005-2018