I am currently developing a Delphi XE5 VCL Forms Application which includes a TIdHTTPServer
on the main form. Within this server, there is a CommandGet
procedure called IdHTTPServer
:
procedure TForm1.IdHTTPServerCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var responce: TStringList;
begin
if pos('someString', ARequestInfo.UnparsedParams) > 0 then
begin
responce:= TStringList.Create;
try
responce.Add('<html>');
responce.Add('<head>');
responce.Add('<title>Index</title>');
responce.Add('<script src="E:\ProjectFolder\script.js"></script>')
responce.Add('</head>');
// HTML content
responce.Add('</html>');
AResponseInfo.ContentText := responce.Text;
finally
responce.Free;
end;
end;
end;
One issue I have encountered is that when I change the directory of the project, the .js file becomes inaccessible to the browser. How can I adjust the reference to the .js file so that it remains accessible even if the project directory changes?