Adr*_*rea 5 python macos terminal simplehttpserver tmux
LSOpenURLsWithRole() failed with error -600 for the URL http://localhost:9000/.
这是我尝试SimpleHTTPServer在tmux会话中启动时遇到的错误.我是一名前端Web开发人员,而且我大部分时间都在使用a SimpleHTTPServer而不是Apache.问题是它在open命令错误,因为我习惯直接从终端打开文件和目录(open dirname/,或open .),当我使用它时,tmux它给我同样的错误.我想提一下,我在Macbook Air上运行OSX 10.9 Mavericks.
这是我在终端中用来启动服务器的函数的代码:
# Start an HTTP server from a directory, optionally specifying the port
function server() {
local port="${1:-8000}"
open "http://localhost:${port}/"
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}
Run Code Online (Sandbox Code Playgroud)
问题不再出现所以我有3个可能的解决方案:
不大可能:
最有可能的:
不确定这对你来说是否是同样的情况,因为你提到你重新启动了几次......
然而对我来说,我注意到在 iterm 失败后我有 2 个 tmux 会话,但我已经忘记了。他们正在运行一堆由 grunt 启动的服务,所以我假设其中一个服务在尝试重新启动时发生冲突。杀死它们使错误不再发生,并且我能够在 tmux 中运行我的节点应用程序。
| 归档时间: |
|
| 查看次数: |
2732 次 |
| 最近记录: |