Genie.jl, global session variables

I need to write a very easy web application, in which I need to use Julia’s function. So I try to use Genie. To be honest, I don’t find good documentation, even the official doc isn’t full.

I wrote the simplest example. I need to understand how to work session variables.

using Genie, Genie.Router, Genie.Requests, Genie.Renderer.Html
function main()
i=1
route(“/test”) do
i = i+1
“test $i”
end
up()
end
main()

Would you suggest, how to create global variables for the session? Right now I have global variable for the whole site.

Thank you

P.S. Maybe you can suggest other libraries. Everything that I need, just to work with Get and Post request.

If you want to try other libraries, then maybe something of this would be useful:

Also you can take a look at DiffEqOnlineServer.

I would add to list my new lightweight web framework: dance.jl.

As per docs:

using Dance.Router

i = 0

function test() :: String
   global i
   i = i+1
   return ""
end

route("/", test; endpoint=HTML, method=GET)

Once you end session, i will be 0 again

Hey, I hope you could already solve your problem. I dont have a good answer to your global variables, but a simple server setup which works fine for get and post could be:

import Genie: up
import Genie.Router: route, POST
import Genie.Requests: jsonpayload

function do_something()
	jsonpayload()
end

function run_server()
	route("/", () -> (:message => "Hey there!"))
	route("/myroute", do_something, method=POST)
	up(8000, async = false)
end