I have an angular project that I want to deploy using swifter in swiftUI. I have tried the below code.
import Foundation
import Swifter
class WebServer {
let server = HttpServer()
let path: String
init(path: String) {
self.path = path
}
func startServer() {
if let webAppPath = Bundle.main.path(forResource: "index", ofType: "html", inDirectory: "/Users/user/Downloads/dirFile") {
// Serve the Flutter web build files
server["/"] = shareFilesFromDirectory(webAppPath)
do {
try server.start(8081)
print("Web server started on port 8081")
} catch {
print("Failed to start the web server: \(error)")
}
} else {
print("Web app path not found.")
}
}
func stopServer() {
server.stop()
print("Web server stopped")
}
}
When trying this, I am getting the following error:
Web app path not found.
I have tried giving path of the directory where my web application is from both, separate directory, and copied angular project directory in the Xcode project (Both gives the same result). Can someone help me out?