Version 0 of Toolatra

Updated 2019-11-06 13:35:26 by timkoi

https://raw.githubusercontent.com/timkoi/toolatra/master/logo.png

Toolatra

Toolatra is a modern Sinatra-like micro web framework for writing HTTP Tcl web applications.

Features

  • Sinatra-like DSL
  • does not depend on anything, except for Tcllib (though, Toolatra works only with Tcl 8.5 and newer)
  • a built-in template engine and layout engine
  • a built-in web server that easily integrates with Apache or nginx

Some examples

Hello world

app.tcl code:

#!/usr/bin/env tclsh
package require Toolatra

get / {
     render {Hello world!}
}

get /+name {
     render "Hello, [dict get $params name]!"
}

post / {
     if {$rawData != {}} {
         render "Hello, $rawData (via POST request)!" 
     } else {
         render {Hello world (via POST request)!} 
     }
}

run

How to run:

$ tclsh8.5 app.tcl

The app will be running at http://localhost:5050

  • If you go to http://localhost:5050 via your web browser, you should see Hello world!
  • If you go to http://localhost:5050/Tim via your web browser, you should see Hello, Tim!
  • If you send an empty POST request to http://localhost:5050 , you should get Hello world (via POST request)!
  • If you send a POST request with Jane sent as the data, you should get Hello, Jane (via POST request)!

Cat Language Translator

Both the current and the previous version of Cat Language Translator are written 100% in Tcl and Toolatra. The source code of the first version can be found here: https://github.com/timkoi/catlanguage-web

Links

Toolatra git repo: https://github.com/timkoi/toolatra Bug tracker: https://github.com/timkoi/toolatra/issues