silvioprog / brookframework

Microframework which helps to develop web Pascal applications.
https://github.com/risoflora/brookframework
GNU Lesser General Public License v3.0
171 stars 37 forks source link

How can I send to the client a static file in the root directory with the app? #146

Closed Al-Muhandis closed 6 years ago

Al-Muhandis commented 7 years ago

I use directory with static files (css, js and so on) by means BrookStaticFileBroker. But if I must to place static file in the root url? For example, robots.txt. With the condition that in Apache set alias from the root url to the app in the cgi-bin folder.

leledumbo commented 7 years ago
{$mode objfpc}{$H+}

uses
  fpmimetypes, BrookUtils, BrookFCLHTTPAppBroker, BrookApplication, BrookStaticFileBroker;

begin
  MimeTypes.LoadFromFile('/etc/mime.types'); // skip if you don't have one, then everything will be of content-type application/octet-stream
  BrookStaticFileRegisterDirectory('/','/real/path/in/your/filesystem');
  BrookSettings.Port := 9000;
  Application.Run;
end.
Al-Muhandis commented 7 years ago

Thank very much... I tried this option, but the application apparently gets stuck in a loop (Out of memory HTTP 500) because of alias in the Apache settings ScriptAlias / /var/www/user1/data/www/mysite_example.com/cgi-bin/index.fcgi/

leledumbo commented 7 years ago

Well... don't use that alias then, let the application handle it.

Al-Muhandis commented 7 years ago

Thank you

silvioprog commented 6 years ago

Closing since the problem was fixed. Thanks for reporting @Al-Muhandis !