ESPAsyncWebServer.h , g_OTA_server.on( , how to insert a link

Hello:

Running Linux Mint 22, VSCode 1.127, programming an ESP8266.

I am attempting to insert 2 links in the setup for a web server.

Please forgive me if this is the wrong area, or even the wrong forum for this question.

What I have…

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESPAsyncWebServer.h>
#include <WebSerial.h>
#include <ElegantOTA.h>
// more includes here

...

AsyncWebServer g_OTA_server(80);

...

void setup() {
   ... //start wifi, other init stuff

   g_OTA_server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
     char ota_info_str[256];
     char our_ip_address[20];

     sprintf(our_ip_address, "%s", WiFi.localIP().toString().c_str());
     sprintf(ota_info_str, 
          "%s\nElegantOTA is at <a href=\"http://%s/update\">http://%s/update</a>\nWebSerial is at http://%s:81/webserial", 
          TITLE,
          our_ip_address,
          our_ip_address, 
          our_ip_address);
     request->send(200, "text/plain", ota_info_str);
	});

// I am including this for context, I am not asking about this for now.

	g_webserial_server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
char web_info_str[128];
	sprintf(web_info_str, "%s\nWebSerial at http://%s:81/webserial\nElegantOTA is at http://%s/update", TITLE, WiFi.localIP().toString().c_str(), WiFi.localIP().toString().c_str());
		request->send(200, "text/plain", web_info_str);
	});

};

Here is the output on the web page…

8266_IRRIGATE_SHOP
ElegantOTA is at <a href="http://192.168.0.43/update">http://192.168.0.43/update</a>
WebSerial is at http://192.168.0.43:81/webserialFor the most part, all of this works in that it compiles and runs fine, however…

As you can see, I want to make a link such that I can simply click to bring me to the OTA however it is printing the <a href= instead of interpreting it as a link.

If I manually copy the text, and paste it into the URL, it works so I think it is formatted properly expected.

Can someone help me please?

Thanks, Mark.

So you’re sending HTML code but mark it as text/plain? Use the MIME type text/html instead.

See https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types

Thank you maxgerhardt, that did the trick. Clearly, I know c better then I do HTML.

That also cleared up the newline issue I was working on. I tried to put
to get a newline, but that didn’t do it, only \n worked. That is now working as expected too.

Thanks again, Mark