Beginning with a simple example – Hello World

Let's take a look at a simple example of employing the HTTP server stack. This will help us understand the foundational building blocks before we dive into the more complex issue of exposing our game on the web.

If you followed the previous chapter, you should already have the HTTP package installed. If not, you know the drill—run pkg> add HTTP in Julia's REPL.

Now, somewhere on your computer, create a new file called hello.jl. Since this will be a simple piece of software contained in just one file, there's no need to define a module. Here is the full code, the whole eight lines, in all their glory. We'll go over them next:

using HTTP, Socketsconst HOST = ip"0.0.0.0"const PORT = 9999router = ...

Get Julia 1.0 Programming Complete Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.