ToolipsRemote.jl

Serve clients in julia with toolips!
Author ChifiSource
Popularity
5 Stars
Updated Last
1 Year Ago
Started In
June 2022

  • Documentation
  • Toolips
  • Extension Gallery
    Toolips Remote allows you to connect to your server from the Julia REPL. Simply load the Remote extension into your server, and then use the connect function to connect to it. You will then be prompted to login!

quick start

First, inside of your toolips project's source file, add Remote to your Vector{ServerExtension}.

routes = [route("/", home), fourofour]
extensions = Vector{ServerExtension}([Logger(), Remote(Dict{Int64, Function}(1 => home))])
"""
start(IP::String, PORT::Integer, ) -> ::ToolipsServer
--------------------
The start function starts the WebServer.
"""
function start(IP::String = "127.0.0.1", PORT::Integer = 8000)
     ws = WebServer(IP, PORT, routes = routes, extensions = extensions)
     ws.start(); ws
end

Functions can be changed by providing to the first postional argument a Dict{Int64, Function} with a different function for each user group, represented by an Int64. Users can be changed by modifying the users Vector right after it, passwords can promptly and easily be changed using the set_pwd method. Of course, this can also be provided via an environmental variable. When writing a Remote function, make sure that there is a method for a single positional argument either of type AbstractConnnection or RemoteConnection. If your function is annotated as an AbstractConnection, you could even use the same exact route that serves your website.

function home(c::AbstractConnection)
    mydivider = div("mydivider")
    push!(mydivider, h("helloworld", 1, text = "hello world!"))
    push!(mydivider, a("toolips-link", text = "toolips :)",
    href = "https://toolips.app"))
    write!(c, mydivider)
end

Once our ToolipsServer is started, we can use the connect method in order to connect to our server.

julia> using ToolipsRemote

julia> connect("http://127.0.0.1:8000")
  login to toolips remote session
  –––––––––––––––––––––––––––––––––
user: root
password for root: 
  connection successful!
  ------------------------
REPL mode remote initialized. Press [ to enter and backspace to exit.
"Prompt(\"🔗 root> \",...)"

🔗 root> showexample
  ────────────────────────────────────────────────────────────────────────────

  hello world!
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  toolips :) (https://toolips.app)–-

Used By Packages

No packages found.