diff --git a/browser/html/admin-settings.html b/browser/html/admin-settings.html new file mode 100644 index 000000000000..276ca6329124 --- /dev/null +++ b/browser/html/admin-settings.html @@ -0,0 +1,83 @@ + + + + + Admin Setting Iframe + + + +

Admin Setting Iframe

+
+
+
+ + +

+
+ + + + diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index c094e211d37c..d41a6f4693ab 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -600,6 +600,54 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, } } + if (endPoint == "admin-settings.html") + { + try + { + std::string templatePath = COOLWSD::FileServerRoot + "/browser/dist/admin-settings.html"; + + std::string htmlContent = readFileToString(templatePath); + if (htmlContent.empty()) + { + throw std::runtime_error("HTML file is empty or could not be read"); + } + + Poco::Net::HTTPResponse httpResponse(Poco::Net::HTTPResponse::HTTP_OK); + httpResponse.setContentType("text/html"); + httpResponse.setContentLength(htmlContent.size()); + + std::ostringstream headerStream; + headerStream << "HTTP/1.1 " << httpResponse.getStatus() << " " << httpResponse.getReason() + << "\r\nContent-Type: " << httpResponse.getContentType() + << "\r\nContent-Length: " << httpResponse.getContentLength() << "\r\n\r\n"; + std::string headers = headerStream.str(); + + socket->send(headers.data(), headers.size()); + + socket->send(htmlContent.data(), htmlContent.size()); + } + catch (const std::exception& e) + { + Poco::Net::HTTPResponse errorResponse(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); + errorResponse.setContentType("text/plain"); + + std::string errorMessage = "Error: " + std::string(e.what()); + errorResponse.setContentLength(errorMessage.size()); + + std::ostringstream errorHeaderStream; + errorHeaderStream << "HTTP/1.1 " << errorResponse.getStatus() << " " << errorResponse.getReason() + << "\r\nContent-Type: " << errorResponse.getContentType() + << "\r\nContent-Length: " << errorResponse.getContentLength() << "\r\n\r\n"; + std::string errorHeaders = errorHeaderStream.str(); + + socket->send(errorHeaders.data(), errorHeaders.size()); + + socket->send(errorMessage.data(), errorMessage.size()); + } + + return; + } + // Is this a file we read at startup - if not; it's not for serving. if (FileHash.find(relPath) == FileHash.end() && FileHash.find(relPath + ".br") == FileHash.end())