Running an App in the Browser
CloudTk
To bring your application onto the browser you have to do the following steps:
- Wrap your application to an linux executable (x86_64 or arm32)
- copy your wrapped application to the linux machine
- be sure, that Xvnc with his dependencies is installed on the linux machine
- Start your application with the option "-runctk"
-
You can also use the following additional options:
Option Description Default -ctkport http-Port 8015 -ctksslport https-Port 8016 -ctkuserid Userid under which the App will run the id of the current user -
Open your Browser and enjoy your App
- There is no need to have an running X-Server on your linux-machine, just Xvnc and the needed libraries have to be installed.
Certificates
In the tclexecomp binary, there are 2 certificates included which are used on the CloudTk-https Server. If you want to use your own certificates, you have to wrap them into the binary, puts them in the cloudtk-certs directory and call them server.pem and skey.pem.
So your wrap directory should look like this:
wrap/
<appname.tcl>
cloudtk-certs/
server.pem
skey.pem
CloudTk namespace
If your wrapped application is started, a new namespace called cloudtk is also created.
In this namespace there exists a variable cloudtk::cloudtk. It is set to "1", if your App is started in Cloudtk and has the value "0", if not. So your App knows how is it started.
If your App is started in CloudTk, open/save a file should be handled by the browser and not as an access to the filesystem, where your app run's. If not, the external User has over the browser access to your filesystem where CloudTk is running. That's not what we want.
So there are functions in the CloudTk-namespace to handle these situations:
-
To save a file in an CloudTk running App, the function cloudtk::download should be used. It has 2 arguments: filename and data. If it is called you got downloaded an file with that name and the data over the browser
-
To load/open a file in an CloudTk running App, the function cloudtk::request_upload should be used. It has no arguments, opens a popup in the browser and returns a list of 3 values:
- status:
- filename: if status is ok, it contains the chosen filename
- data: if status is ok, it contains the data of the chosen filename
- status:
The communication with the browser is handled over Javascript in the background transparently, in your application you only have to check on running in CloudTk and call these 2 functions for opening or saving a file.