Book Image

Web Development with Julia and Genie

By : Ivo Balbaert, Adrian Salceanu
Book Image

Web Development with Julia and Genie

By: Ivo Balbaert, Adrian Salceanu

Overview of this book

Julia’s high-performance and scalability characteristics and its extensive number of packages for visualizing data make it an excellent fit for developing web apps, web services, and web dashboards. The two parts of this book provide complete coverage to build your skills in web development. First, you'll refresh your knowledge of the main concepts in Julia that will further be used in web development. Then, you’ll use Julia’s standard web packages and examine how the building blocks of the web such as TCP-IP, web sockets, HTTP protocol, and so on are implemented in Julia’s standard library. Each topic is discussed and developed into code that you can apply in new projects, from static websites to dashboards. You’ll also understand how to choose the right Julia framework for a project. The second part of the book talks about the Genie framework. You’ll learn how to build a traditional to do app following the MVC design pattern. Next, you’ll add a REST API to this project, including testing and documentation. Later, you’ll explore the various ways of deploying an app in production, including authentication functionality. Finally, you’ll work on an interactive data dashboard, making various chart types and filters. By the end of this book, you’ll be able to build interactive web solutions on a large scale with a Julia-based web framework.
Table of Contents (13 chapters)
1
Part 1: Developing Web Apps with Julia
5
Part 2: Using the Genie Rapid Web Development Framework

Using WebSockets

WebSocket (ws://URL), or wss://URL for WebSocket Secure, is a bidirectional, low-latency, and high-speed protocol that builds on the TCP protocol. It uses HTTP(S) to make the connections (using ports 80 and 443, respectively), so it also needs the HTTP package. In a way, it combines characteristics of both UDP and TCP; it is message-based like UDP but also reliable and stateful like TCP. Chat services are among the most popular applications of WebSockets.

You can read data from or write data to a WebSocket, send ping or pong messages, and close the connection.

The WebSockets package can be found at https://github.com/JuliaWeb/WebSockets.jl, which contains a complete example of the chat service.

To start using the WebSockets package, add it via the REPL’s package mode:

(@v1.8) pkg> add WebSockets

The preceding command installs dependent packages such as URIs and HTTP and then precompiles them.

To set up a WebSocket, you need a URL and a...