First things first, you can find the web app at countdown.gobs.eu. Repository for web app is here.

Probably about 2 months ago I had the brilliant idea of attempting to create a Julia web app. Since this took me a while, I thought I'd document my struggles here in case anyone else wants to try this out. This is mostly just things I realised along the way rather than a proper tutorial. For more useful information, check out the following ressources:

TL;DR - read this if you're comfortable with Julia but not with web stuff (and if you don't mind liberal use of the words "stuff" and "things"). Otherwise the above links will be more useful to you.

What is a web app?

I don't have a formal definition, but for me it's "something that runs in your browser" and hence "can be put on a server so that other people can use it without knowing about or running Julia" (you could replace Julia with other languages, e.g. Python). So for me, an interactive Jupyter notebook is a web app of some sorts. I assume that this as an abuse of technical language.

Deploying Julia on a server

This might seem obvious, but Julia needs to be installed on your server to do this. And when people interact with the web app, they're using up ressources on your server. This is generally not a great idea if you have lots of people using your web app as you might imagine. This is why people usually code these in JavaScript, which is run on your (the person visiting the web app's) browser. But doing that defeated the purpose, since I wanted to do it in Julia.

What to use?

There are a bunch of Julia packages for web apps or similar stuff, but in the end I went with Genie.jl / Stipple.jl. I'm actually not sure what the difference between Genie and Stipple is - I think Genie uses Stipple for interactive componenents, but you only need Stipple for a web app. I suppose if you want more features (I don't know what those would be) then go with a Genie app. I also seemed to find more ressources online if you go down the Genie app route.

How to build a web app?

Currently documentation is a bit scant with Genie and Stipple (I have no doubt that will improve soon), but with a bit of persistence you can get by. I recommend just copying and altering examples you can find online, e.g. these Stipple Demods. I think the lack of documentation is also less of a problem if you know your way around HTML and web stuff generally. For inspiration, you can find my git repository for the Countdown Solver here.

Deploying a Julia web app on an existing server

You're reading this article on my Hetzner web server, which already uses Nginx. My initial idea was to somehow have the web app set up in such a way that you could go to gobs.eu/countdown-solver and you would be greeted with the web app. This is actually not as easy as it sounds, so I went with the suggestion I was given here of using a reverse proxy. This meant the web app could be found at countdown.gobs.eu.

If you're wondering what a reverse proxy is, this is my understanding of how it works for my case:

  • You write in your browser countdown.gobs.eu
  • Thanks to domain name servers (DNS), you are sent to my server's IP address through port 80 (the default port for HTTP)
  • Nginx sees that you wanted to go to countdown.gobs.eu, which is configured to redirect you to the web app which is running on (in my case) port 9000. In this way, your server could host many different web apps (or even websites) - all you need is to specify subdomains (the countdown in countdown.gobs.eu) for each web app and configure Nginx to redirect visitors to the correct port.

You can find more specific info on how I set this up on my server here. Main thing I would point out is that the configuration file needs to be present in /etc/nginx/sites-enabled! Initially I only had it in /etc/nginx/conf.d and I spent quite a while trying to figure out what was wrong.

Still to do?

There's some additional things I should (but probably won't) do:

  • Setup a supervisor to restart the Stipple app when I restart my server as described here)
  • Clean up the web app a bit - right now there's nothing which tells you it's solving for example. I imagine that some people might also be confused at the double backslash notation (//) for rational numbers.

In conclusion

I'd like to give a assive thank you to essenciary, developer of Genie.jl, for helping me out with this. I just hope the trivial use case doesn't make them regret helping me.

Previous Post