httpswift / swifter

Tiny http server engine written in Swift programming language.
BSD 3-Clause "New" or "Revised" License
3.9k stars 539 forks source link

Use local host local server open html with the first server not active, to be public with the time open next #511

Open anhvu1993 opened 2 years ago

anhvu1993 commented 2 years ago

[Question] I am using Server local host to open an html on safari with the following error: safari cannot open the page because it could not connect to the server. let localServer = HttpServer() let html = htmlFor(title: GlobalManager.shared.typeAppMakeIcon.name, urlToRedirect: deepLinkUrl, iconBase64: iconBase64, iconTutorial: tutorialBase64) guard let base64 = html.data(using: .utf8)?.base64EncodedString() else { return } localServer?["/s"] = { request in return .movedPermanently("data:text/html;base64,\(base64)") } try? localServer?.start(in_port_t(serverRandom)) UIApplication.shared.open(shortcutUrl)

huynguyen1991 commented 1 year ago

@anhvu1993 : vấn đề này giải quyết được chưa bạn, share mình giải pháp với. Tks!