       path = request->arg( "filename" );
     }
 
-    if ( xSemaphoreTake( x_SPI_Mutex, SPI_MutexMaxWaitTime ) )
-    {
-      if ( !SD.exists( path ) )
-      {
-        path = request->arg( "filename" ) + " not found.";
-        return request->send( 404, textPlainHeader, path );
-      }
-
-      SD.remove( path );
+    if ( !SD.exists( path ) )
+    {
+      path = request->arg( "filename" ) + " not found.";
+      return request->send( 404, textPlainHeader, path );
+    }
+    SD.remove( path );
+    path = request->arg( "filename" ) + " deleted.";
+    xSemaphoreGive( x_SPI_Mutex );
+    request->send( 200, textPlainHeader, path );
+  });
+
+  server.onNotFound( []( AsyncWebServerRequest * request )
+  {
+    const char* notFound = "NOT_FOUND: ";
+
+    if ( request->method() == HTTP_GET )
+    {
+      if ( !xSemaphoreTake( x_SPI_Mutex, SPI_MutexMaxWaitTime ) )
+      {
+        return request->send( 501, textPlainHeader, "SPI bus not available" );
+      }
+
+      if ( SD.exists( request->url() ) )
+      {
+        request->send( SD, request->url() );
+        xSemaphoreGive( x_SPI_Mutex );
+        return;
+      }
       xSemaphoreGive( x_SPI_Mutex );
-    }
+      Serial.printf( "%s GET", notFound );
+    }
+    else if (request->method() == HTTP_POST)
+      Serial.printf("%s POST", notFound );
+    else if (request->method() == HTTP_DELETE)
+      Serial.printf("%s DELETE", notFound );
+    else if (request->method() == HTTP_PUT)
+      Serial.printf("%s PUT", notFound );
+    else if (request->method() == HTTP_PATCH)
+      Serial.printf("%s PATCH", notFound );
+    else if (request->method() == HTTP_HEAD)
+      Serial.printf("%s HEAD", notFound );
+    else if (request->method() == HTTP_OPTIONS)
+      Serial.printf("%s OPTIONS", notFound );
     else
-    {
-      return request->send( 503, textPlainHeader, "SPI bus not available." );
-    }
-
-    path = request->arg( "filename" ) + " deleted.";
-    request->send( 200, textPlainHeader, path );
-  });
-
-  server.onNotFound( []( AsyncWebServerRequest * request )
-  {
-    const char* notFound = "NOT_FOUND: ";
-
-    if ( request->method() == HTTP_GET )
-    {
-      if ( xSemaphoreTake( x_SPI_Mutex, SPI_MutexMaxWaitTime ) )
-      {
-        if ( SD.exists( request->url() ) )
-        {
-          request->send( SD, request->url() );
-          xSemaphoreGive( x_SPI_Mutex );
-          return;
-        }
-        xSemaphoreGive( x_SPI_Mutex );
-      }
-      else
-      {
-        Serial.println( "Server->SPI bus not available." );
-      }
-      Serial.printf( "%s GET",notFound );
-    }
-    else if (request->method() == HTTP_POST)
-      Serial.printf("%s POST",notFound );
-    else if (request->method() == HTTP_DELETE)
-      Serial.printf("%s DELETE",notFound );
-    else if (request->method() == HTTP_PUT)
-      Serial.printf("%s PUT",notFound );
-    else if (request->method() == HTTP_PATCH)
-      Serial.printf("%s PATCH",notFound );
-    else if (request->method() == HTTP_HEAD)
-      Serial.printf("%s HEAD",notFound );
-    else if (request->method() == HTTP_OPTIONS)
-      Serial.printf("%s OPTIONS",notFound );
-    else
-      Serial.printf("%s UNKNOWN",notFound );
+      Serial.printf("%s UNKNOWN", notFound );
     Serial.printf(" http://%s%s\n", request->host().c_str(), request->url().c_str());
     request->send( 404 );
   });

      tft.fillScreen( ILI9341_BLACK );
      saveStringNVS( "tftorientation", ( tftOrientation == TFT_ORIENTATION_NORMAL ) ? "normal" : "upsidedown" );
      snprintf( content, sizeof( content ), "%s", ( tftOrientation == TFT_ORIENTATION_NORMAL ) ? "normal" : "upsidedown" );
    }




  server.on( "/api/deletefile", HTTP_POST, []( AsyncWebServerRequest * request)
  {
    if ( !xSemaphoreTake( x_SPI_Mutex, SPI_MutexMaxWaitTime ) )
    {
      return request->send( 501, textPlainHeader, "SPI Bus not available" );
    }

    if ( !request->authenticate( www_username, www_password ) )
    {
      return request->requestAuthentication();
