Telegraph
Telegraph copied to clipboard
serverHTTP.serveDirectory(Bundle.main.url(forResource: "Demo", withExtension: nil)!) can not runing
trafficstars
I followed the docs, expecting me to reference my Bundle.main.resourceURL/Demo directory; but Bundle.main.url(forResource: "Demo", withExtension: nil) returns nil;
Search for issues and find URL(string: "Demo", relativeTo:Bundle.main.resourceURL), but it cannot be applied to the correct directory;
Later, I found that using Bundle.main.resourceURL can be applied to files under Demo, but it has no directory hierarchy, so the files are all in the root directory;
debugPrint(Bundle.main.resourceURL)
debugPrint(Bundle.main.bundleURL)
let demoBundleURL = Bundle.main.url(forResource: "Demo", withExtension: nil)
let testBundleURL = URL(string: "Demo", relativeTo:Bundle.main.resourceURL)
let testBundleURL1 = URL(string: "js.js", relativeTo:Bundle.main.resourceURL)
serverHTTP.serveDirectory(Bundle.main.resourceURL!)
serverHTTP.delegate = self
serverHTTP.webSocketDelegate = self
try serverHTTP.start(port: port)
demoClientNormalRequest()
https://bayibintuan-img.obs.cn-east-3.myhuaweicloud.com/merchant0/3358473884961772_1689313293420.png I want to know if I wrote it wrong