Ok, the problem is the FServer.Active := true;
That just starts the listening server and execution stops until a response is received.
So it's essentially a loop itself so you can remove the while not terminated again.
You need to add the DoTerminate again to be able to stop the FServer.
But the problem is, that the DoTerminate is never executed in the thread anymore.
(you can see that by putting showmessages or breakpoints in the right places)
I'm not familiar with the TFPHTTPServer in a thread.
You could try to stop the server directory instead of calling Terminate but that didn't work for me either.
what are the options for Windows in this case? Synapse?
thank you
what are the options for Windows in this case? Synapse?It seems that the latest version 1.8RC2 with FPC 3.1.1 can stop the server under Windows with FServer.Active := False;
Please advise why you would think is working with the FPC3.1.1 version?I tested it and it worked :)
... I would like to be able to do it from the same program without users having to install anything.So the target computer doesn't have a browser? And you don't want to install or rely on an external browser?
I would like the application to have an integrated web server so that the user does not have to install any WAMP type server and that when the preview is made it opens in the browser under an http server.Ok, that makes it clearer.
When I saw the rvk code I thought it was what I was looking for but my problem is that I don't know in which path I should create the files to call localhost:8001 from the system's default browser.
01taller/01taller.htm
01taller/01tallerProble_resources/css/ardoraTest.css
01taller/01tallerProble_resources/js/jquery.js
01taller/01tallerProble_resources/js/jquery-ui.min.js
01taller/01tallerProble_resources/js/jquery.ui.touch-punch.min.js
01taller/01tallerProble_resources/js/ardoraTestCFG.js
01taller/01tallerProble_resources/js/ardoraScorm.js
01taller/01tallerProble_resources/js/ardoraTest.js
01taller/01tallerProble_resources/js/ardoraTab.js
remove wmecho from the uses clause.@Thaddy Can you explain, why removing wmecho from uses clause resolves problem?
Works.Did you try the example of TS?
Because wmecho is not needed and makes it fail to compile because it can not be found.I don't know if wmecho is needed. I have found this unit. After successfully compilation and run open chrom and make request, app fails with exception.
After that, try to start the server and ask for a page (must exist) like index.html.
Works.
No. I got a compile error in trunk, removed the unit and tested basic functionality. The simpleserver works and serves what you ask. I did not test anything else.Yes, neat. It works with one index.htm :(
Hi rvk.Install Apache or nginx ... and you have working solution.
Yes, I tested the simplehttpserver on W7 with firefox and chrome and it works after commenting the line "if FCount>=5 then Active:=false" as it prevented the complete loading of all files.
As anecdote, the avast antivirus considers simplehttpserver a "threat".
However there is something "strange", when closing the browser the exception "EHTTPServer" appears with the message: "Missing HTTP protocol version in request". If we click on the continue button of the exception message the server is still working.
I have placed in the code the line "Arequest.ProtocolVersion:='HTTP/1.1';" but it doesn't seem to solve it.
I have tried a bigger web (several html+css+js), the only problem is that when, from the web, a new html file is requested, the exception reappears. Clicking on the continue button of the exception message continues to work and loads the html, even html inserted into iframes.
However there is something "strange", when closing the browser the exception "EHTTPServer" appears with the message: "Missing HTTP protocol version in request". If we click on the continue button of the exception message the server is still working.Intentional, the exception actually happens internally and handled gracefully without ever leaking out of the webserver unit code. But GDB will still catch it unless you whitelist it.
Install Apache or nginx ... and you have working solution.
I have same exception.
Intentional, the exception actually happens internally and handled gracefully without ever leaking out of the webserver unit code. But GDB will still catch it unless you whitelist it.Indeed, once compiled there is no problem, maybe a little slow but everything seems to work fine.
Check - https://wiki.freepascal.org/Brook_for_Free_PascalInstall Apache or nginx ... and you have working solution.
I have same exception.
Yeah, it's the solution I'm using for my application. But if I could insert an http server into my application, users would no longer have to "add" anything. If that server also supported php it would be perfect.
Hi julkas. THanks for the feedback. I'm gonna try it.there are two Brook projects -