Bookstore

Recent

Author Topic: Web server, which component?  (Read 970 times)

kupferstecher

  • Sr. Member
  • ****
  • Posts: 361
Web server, which component?
« on: February 28, 2020, 07:40:32 pm »
Hello,

I'm searching for a component to add embedded webserver functionality to a GUI-application. FPWeb was the first trial I made, using the TFPHttpServer. But I have trouble stopping the webserver without killing the application. When searching around I found a statement by the developer, that this component wasn't intended for productive use...

Then I stumbled over the brook framework, but in forum posts it was said that it has memory leaks when restarting the webserver, its only designed to be started once...

So what component is suitable to create an embedded web server that can be started, stopped and restarted within a GUI-application. SSL and authentification should be possible.

Thanks for some advice!

Regards~

Renat.Su

  • Full Member
  • ***
  • Posts: 162
    • Renat.Su
Re: Web server, which component?
« Reply #1 on: February 28, 2020, 08:33:53 pm »
Then I stumbled over the brook framework, but in forum posts it was said that it has memory leaks when restarting the webserver, its only designed to be started once...
It is not clear exactly what kind of leaks when restarting the web service? And which fork of the brook exactly? Brook Framework  or Book For Free Pascal?

kupferstecher

  • Sr. Member
  • ****
  • Posts: 361
Re: Web server, which component?
« Reply #2 on: February 28, 2020, 08:51:25 pm »
Hello Renat,

this is the forum post that I mean:
https://forum.lazarus.freepascal.org/index.php/topic,38678.msg264444.html#msg264444
Like I said eerlier, it does have intended memory leaks. I think that author doesn't care about it since by design it will be run just once so even if it leaks, it will be at the program end, which doesn't matter. Now it matters when we want to be able to start and stop the server in a single program indefinitely by some GUI action.
It's from 2017, so things could have changed, of course.

I'm asking here, to get some hints which framework/library is suitable. To avoid starting with an other library that I couldn't get to work. So the fork/framework I did't choose, yet.
Any recommendations are welcome.

Renat.Su

  • Full Member
  • ***
  • Posts: 162
    • Renat.Su
Re: Web server, which component?
« Reply #3 on: February 28, 2020, 09:00:32 pm »

kupferstecher

  • Sr. Member
  • ****
  • Posts: 361
Re: Web server, which component?
« Reply #4 on: February 28, 2020, 09:07:43 pm »
OK, thank You!

So embedding it in a GUI-application works with brook?

Renat.Su

  • Full Member
  • ***
  • Posts: 162
    • Renat.Su
Re: Web server, which component?
« Reply #5 on: February 28, 2020, 09:41:56 pm »
So embedding it in a GUI-application works with brook?
You can ask the author about using in the GUI https://github.com/risoflora/brookfreepascal/issues

zamronypj

  • Jr. Member
  • **
  • Posts: 69
    • Fano Framework, Free Pascal web application framework
Re: Web server, which component?
« Reply #6 on: February 29, 2020, 09:29:48 am »
Do you want to create GUI application that start stop web server like, for example, XAMPP or do you need to embed dynamically generated HTML based UI in GUI application?

If you want to create GUI application that control how web server started stopped, you can run external brook http application through TProcess.

If you intend to embed dynamic generated HTML-based UI, you can generate HTML string on the fly and let embedded browser load from string (or save it to tmp file and load it). This does not require web server at all. You can also use javascript for this

For example

Code: [Select]
data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E

If you paste URL above, browser will output bold text Hello World!
« Last Edit: February 29, 2020, 11:07:31 am by zamronypj »
Fano Framework, Free Pascal web application framework https://fanoframework.github.io
Personal Projects https://v3.juhara.com
Github https://github.com/zamronypj

kupferstecher

  • Sr. Member
  • ****
  • Posts: 361
Re: Web server, which component?
« Reply #7 on: February 29, 2020, 01:41:03 pm »
Hello zamronypj,

the (GUI-) application is for visualization purpose, it includes several interfaces like the serial port, UDP and TCP. The desktop application using LCL shows values and the like, has buttons and so on. By now it's just a desktop application.
Now I want to add some "remote" functionality by adding a web server. The first step would be to provide a screenshot of the application, so the user can check the status from remote by only using a browser. Further steps would be to capture the mouse in the browser with javascript to allow the remote control of the LCL-GUI-application. The application is already quite complex, I couldn't reprogramm it totally as a web-app.

In short: I really need a web server, and the web server has to use data from the LCL-GUI-application, I'm not sure how this could work starting a web server in a (seperate) process.

silvioprog

  • New member
  • *
  • Posts: 6
Re: Web server, which component?
« Reply #8 on: February 29, 2020, 02:46:34 pm »
Hi @kupferstecher.

Are you looking for something like this one in the attached picture?  :) If so, it's a FMX window to start/stop a Brook server, and its source is available here: https://github.com/risoflora/brookframework/tree/master/Examples/FMX. The same example is also available for LCL here: https://github.com/risoflora/brookframework/tree/master/Examples/LCL.

HTH

kupferstecher

  • Sr. Member
  • ****
  • Posts: 361
Re: Web server, which component?
« Reply #9 on: February 29, 2020, 05:11:18 pm »
Hello silvioprog,

that looks good! I'll have a try.

Thanks!

avra

  • Hero Member
  • *****
  • Posts: 1825
    • Additional info
Re: Web server, which component?
« Reply #10 on: March 01, 2020, 09:50:34 am »
The first step would be to provide a screenshot of the application, so the user can check the status from remote by only using a browser. Further steps would be to capture the mouse in the browser with javascript to allow the remote control of the LCL-GUI-application.
Wouldn't VNC server that shares just your app window to clients do the job? Some official VNC servers (with regular or java web server) can share a single window, or you can do it with code.

You can find both server and client for Lazarus here:
https://sourceforge.net/p/dsk/dskvnc/ci/1.0.0.528/tree/

There are also web clients for browsers:
https://chrome.google.com/webstore/detail/vnc®-viewer-for-google-ch/iabmpiboiopbgfabjmgeedhcmjenhbla
https://www.tecmint.com/vnc-desktop-access-from-web-browser/
https://novnc.com/info.html
« Last Edit: March 01, 2020, 10:01:56 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

kupferstecher

  • Sr. Member
  • ****
  • Posts: 361
Re: Web server, which component?
« Reply #11 on: March 01, 2020, 09:59:13 am »
Yes, VNC should do. But then client software has to be installed as well, right?

avra

  • Hero Member
  • *****
  • Posts: 1825
    • Additional info
Re: Web server, which component?
« Reply #12 on: March 01, 2020, 10:02:40 am »
Yes, VNC should do. But then client software has to be installed as well, right?
I have extended my answer.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

kupferstecher

  • Sr. Member
  • ****
  • Posts: 361
Re: Web server, which component?
« Reply #13 on: March 01, 2020, 10:14:36 am »
Thanks, I'll consider that.

But still I want to try to implement it directly (if it doesn't get too much work..).
I tried brook, the server example works, but a DLL is needed. I don't like that too much.
Synapse also comes with a HTTP-server example, it seems a lot of hand work is needed. And I'm not so experienced in networking things.

Jacob21

  • New Member
  • *
  • Posts: 13
Re: Web server, which component?
« Reply #14 on: March 10, 2020, 12:47:06 pm »
Hi @kupferstecher
I wonder if you found a Web Server Solution.
I have a similar requirement and interested in a direction to go (Windows)
Thank you.