I am working on a project in which I must implement a simple web server just to display a welcome page. So I placed a TTCPServer on my form and I can successfully send a plain text to a browser that interacts with the server. But how can I send HTML ?
I tried this but doesn't work.
ClientSocket.Sendln('HTTP/1.0 200 OK');
ClientSocket.Sendln('MIME-version: 1.0');
ClientSocket.Sendln('Content-type: text/html');
ClientSocket.Sendln('Content-Length:'+IntToStr(Length(webpage)+10));
ClientSocket.Sendln(AnsiString(Format(webpage, [va, ma, mi, timexx])));
Any ideas ? I don't want to use another component anyway.
You need an additional CRLF after the last header so the browser can determine end-of-headers and start-of-body.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With