procedure TfMain.IdHTTPServerCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var ms : TMemoryStream;
Requested:
String;
HTML: TStrings;
begin
meInfo.Lines.Add(ARequestInfo.Command);
meInfo.Lines.Add(ARequestInfo.Document);
Requested := ARequestInfo.Document;
if Requested = '
/'
then
Requested := htdocs + '
index.html'
//index.html anfordern
else
Requested := htdocs + Requested;
//anderen content anfordern
//response senden
if FileExists(Requested)
then
begin
//es handelt sich um ein .html file
if Pos('
.html',Requested) > 0
then
begin
PageProducer.HTMLDoc.LoadFromFile(Requested);
AResponseInfo.ContentText := PageProducer.Content;
AResponseInfo.WriteContent;
end else
begin
ms := TMemoryStream.Create;
ms.LoadFromFile(Requested);
AResponseInfo.ContentStream := ms;
AResponseInfo.WriteContent;
ms.CleanupInstance;
end;
end else
AResponseInfo.ContentText := '
Die angeforderte Datei existiert nicht: ' + Requested;
end;