Howdy from Germany.
I try to add a local httpServer with swift-http-server (https://github.com/bjtj/swift-http-server).
import SwiftUI
import SwiftHttpServer
@main
struct MyApp: App {
init() {
print("init")
let server = HttpServer(port: 9090)
class GetHandler: HttpRequestHandler {
var dumpBody: Bool = true
func onHeaderCompleted(header: HttpHeader, request: HttpRequest, response: HttpResponse) throws {
}
func onBodyCompleted(body: Data?, request: HttpRequest, response: HttpResponse) throws {
response.status = .ok
response.data = "Hello".data(using: .utf8)
}
}
do {
try server.route(pattern: "/", handler: GetHandler())
} catch let serverError {
print(serverError)
}
let queue = DispatchQueue.global(qos: .default)
queue.async {
do {
try server.run()
} catch let error {
print(error)
}
}
}
var body: some Scene {
WindowGroup {
ContentView() // Standard ContentView
}
}
}
When I try to add the local network rights on macOS (Montery 12.4 21F79) in the Playgrounds.app (Version 4.1 (1676.15)) it crashes everytime I hit the (+) button.
On iPad (Air 4th gen) with latest ipadOS it works fine. I can add the network rights and can serve the little hello page, by entering :9090/
As mentioned on macOS not possible. Of couse if I reload the Playgrounds project on the Mac, the local network rights are now included, but still on the mac the "Hello" page is not served.
Any hints/tips how to solve this problem? Need I to add more rights? Do I have to report the crash somewhere? I have the crashlog.
Thanks in advance.
Alex
PS: Background: I try to write a Playgrounds App which generates some output on a webpage, which then is served via the in-app webserver, which then is integrated on Obs via web page plugin...