sorry for my English.
Hello, I am having a doubt with the esp8266, I am putting together a tool that through an arduino nano I receive information that is sent and displayed on a page through the esp8266, what I cannot do is generate a button that, when pressed, downloads in this case the "/data.txt" when pressing the button
#include <ESP8266WiFi.h>
#include <FS.h>
#include <ESP8266mDNS.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <SPIFFSEditor.h>
#include <EEPROM.h>
#define BAUD_RATE 115200
const char *ssid = "Telecentrologger";
const char *password = "root3030";
AsyncWebServer server(80);
FSInfo fs_info;
File f;
void setup() {
Serial.begin(BAUD_RATE);
WiFi.mode(WIFI_STA);
WiFi.softAP(ssid,password);
EEPROM.begin(4096);
SPIFFS.begin();
MDNS.addService("http","tcp",80);
f = SPIFFS.open("/data.txt", "a+");
if(!f) Serial.println("Fallo al abrir el archivo");
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/data.txt", "text/plain");
});
server.on("/clear", HTTP_GET, [](AsyncWebServerRequest *request){
f.close();
f = SPIFFS.open("/data.txt", "w");
request->send(200, "text/plain", "file cleared!");
});
server.begin();
}
void loop() {
if(Serial.available()) {
f.write(Serial.read());
}
}