       delay(offms);
     }
 }
+
+boolean getConfiguration() {
+     // open the file in write mode
+    File f = SPIFFS.open("/f.txt", "r");
+    if (!f) {
+      Serial.println("file open failed");
+      return false;
+    }
+    String line = f.readStringUntil('\n');
+    Serial.println(line);
+    ssid = getParam(line,"ssid");
+    password = getParam(line,"password");
+    stream_id = getParam(line,"stream_id");
+    stream_pk = getParam(line,"stream_pk");
+    return true;
+};
+
+void putConfiguration() {
+    // open the file in write mode
+    File f = SPIFFS.open("/f.txt", "w");
+    if (!f) {
+      Serial.println("file creation failed");
+    }
+    // write one URLstyle line
+    f.println(String("ssid=")+ssid +"&password="+password+"&stream_id="+stream_id+"&stream_pk="+stream_pk+"&");
+    f.close();
+};
+

  ssid = getParam(req,"ssid");
  if (ssid != "") {
      password = getParam(req,"password");
      stream_id = getParam(req,"stream-id");
      stream_pk = getParam(req,"stream-pk");
      String doConnect = getParam(req,"connect");
      
      if (doConnect =="Yes" && ssid != "")  {
      wifi_connected = connectWifi();
      if (wifi_connected) {
          response = String("<h1>Connecting to access point Bye Bye</h1>");
  

  pinMode(D1,INPUT);
  pinMode(D4,OUTPUT);
  digitalWrite(D4,HIGH);  // turn it off
  bool result = SPIFFS.begin();
  boolean loadOK;
  loadOK = getConfiguration();
  if (loadOK) {
    wifi_connected = connectWiFi();
  }
  else {
    wifi_connected = false;
  }
}

void loop() {
