2

In R we may use Shiny and in python we could use Streamlit. It seems that in Julia we could use the Genie framework to create web applications. When I am trying to run a simple app, the app doesn't work with up(). I have the following script called app.jl:

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

First we load the app:

Genie.loadapp()

Output:

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

| 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! 

Now start the server:

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

Using the url we get an error saying page not found. So I was wondering if anyone knows how to launch an app with Genie in Julia?

Quinten
  • 35,235
  • 5
  • 20
  • 53
  • They have a comprehensive set of tutorials on their [YouTube](https://www.youtube.com/@genieframework). Checking it would be worthwhile. – Shayan Dec 27 '22 at 18:14

1 Answers1

3

Most likely the port number is already in use which is a standard situation if you run up() more than once.

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)

The error message is not shown in the console but it is available in the object returned by up(). Simply get it into variable (or use the special ans variable having the last REPL result) and peek at the content of wevserver field

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:
...
Przemyslaw Szufel
  • 40,002
  • 3
  • 32
  • 62