Hey ! Habe nun den Fehler gefunden. Es lag an Content-Type. Falls es jemand braucht, So geht der Code :
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
IdHTTPServer1.Active := false;
IdHTTPServer1.DefaultPort := 8888; // Port 8888 ist Standard
try
IdHTTPServer1.Active := true;
except
raise;
end;
if IdHTTPServer1.Active then
begin
label1.Caption := 'Server ist: ONLINE an Port 8888';
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
try
IdHTTPServer1.Active := false;
except
raise;
end;
if not IdHTTPServer1.Active then
begin
Label1.Caption := 'Server ist: OFFLINE';
end;
end;
procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
Var
Stream: TFilestream;
TheString : String;
begin
if ARequestInfo.Document = '/' then begin
AResponseInfo.ContentType := 'image/jpeg';
IF fileexists('test.jpg') = true then ARequestInfo.Document := 'test.jpg';
end;
Stream := TfileStream.Create('test.jpg', fmOpenRead or fmShareDenyWrite );
AResponseInfo.ContentStream := Stream;
setlength(TheString, stream.size);
stream.Read(TheString[1], stream.size);
end;