julia - 在 Julia 中启动 Genie 应用程序时找不到页面

标签 julia genie.jl

在 R 中我们可以使用 Shiny,在 python 中我们可以使用 Streamlit。看来在 Julia 中我们可以使用 Genie 框架来创建 Web 应用程序。当我尝试运行一个简单的应用程序时,该应用程序无法与 up() 配合使用。我有以下名为 app.jl 的脚本:

using Genie
route("/hello") do
    "Welcome to Genie!"
end

首先我们加载应用程序:

Genie.loadapp()

输出:

 ██████╗ ███████╗███╗   ██╗██╗███████╗    ███████╗
██╔════╝ ██╔════╝████╗  ██║██║██╔════╝    ██╔════╝
██║  ███╗█████╗  ██╔██╗ ██║██║█████╗      ███████╗
██║   ██║██╔══╝  ██║╚██╗██║██║██╔══╝      ╚════██║
╚██████╔╝███████╗██║ ╚████║██║███████╗    ███████║
 ╚═════╝ ╚══════╝╚═╝  ╚═══╝╚═╝╚══════╝    ╚══════╝

| Website  https://genieframework.com
| GitHub   https://github.com/genieframework
| Docs     https://genieframework.com/docs
| Discord  https://discord.com/invite/9zyZbD6J7H
| Twitter  https://twitter.com/essenciary

Active env: DEV


Ready! 

现在启动服务器:

up()
┌ Info: 
└ Web Server starting at http://127.0.0.1:8000 
Genie.Server.ServersCollection(Task (failed) @0x00000001471f6770, nothing)

使用该 url,我们收到一条错误消息,指出找不到页面。所以我想知道是否有人知道如何在 Julia 中使用 Genie 启动应用程序?

最佳答案

很可能端口号已被使用,这是如果您多次运行 up() 的标准情况。

julia> up()
┌ Info:
└ Web Server starting at http://127.0.0.1:8000
Genie.Server.ServersCollection(Task (runnable) @0x0000012f0ab07a30, nothing)

julia> up()
┌ Info:
└ Web Server starting at http://127.0.0.1:8000
Genie.Server.ServersCollection(Task (failed) @0x0000012f0bc68010, nothing)

错误消息不会显示在控制台中,但可以在 up() 返回的对象中找到。只需将其放入变量(或使用具有最后 REPL 结果的特殊 ans 变量)并查看 wevserver 字段的内容

julia> status = up()
┌ Info:
└ Web Server starting at http://127.0.0.1:8000
Genie.Server.ServersCollection(Task (failed) @0x0000012ec0c2eca0, nothing)

julia> status.webserver
Task (failed) @0x0000012ec0c2eca0
IOError: listen: address already in use (EADDRINUSE)
Stacktrace:
...

关于julia - 在 Julia 中启动 Genie 应用程序时找不到页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74932568/

相关文章:

centos - 如何在 julia 1.6.2 中安装 Sprite 包?

plot - IJulia 情节 One Liner

julia - Machine 中 X 的 scitype 与模型不兼容

parallel-processing - Julia - 并行数学优化器

dataframe - 如何在 Julia 中将向量的向量转换为 DataFrame,而不需要 for 循环?

python - 使用 Python 与 Julia 进行线性回归的分析解决方案