Skip to content

Advanced use ​

This part is for advanced users and developers:

Retrieving a file ​

We have seen that the script or the notebook being edited can be saved, but how do you retrieve an extra file you changed, or an image you created with Python? It is quite simple: after importing the basthon Python module with import basthon, use the function

python
basthon.download('path/to/my/file.ext')

This opens a window to save the file wherever you want on your machine.

Astuce

A content can also be downloaded directly, without going through a file: basthon.download('message.txt', 'Hello!').

Info

The basthon Python module is documented in more detail on the API of the basthon Python module page.

In the other languages:

LanguageDownloading a file
OCamlBasthon.download "path/to/my/file.ext" (OCaml's Basthon module, see Basthon.help ())
JavaScriptbasthon.download("Hello!", "message.txt") (the content, text or bytes, then the name of the file)
SQL.export (database in binary format) or .dump (in SQL format), see SQL
Cbasthon_download("path/to/my/file.ext") (<basthon.h>, see C)

The R and XCAS kernels cannot download a file for now.

Hosting Basthon on your own web server ​

Basthon's interfaces are static sites: to install them on your own web server, download their archive and extract it wherever you want.

A few resources, too big for the archives or provided by services, are still downloaded from other servers:

ResourceDownloaded fromWhen
Pyodide (the Python interpreter)cdn.basthon.fr or, failing that, Pyodide's CDN (jsDelivr)when the Python kernel starts
a few pure Python packages (qrcode, folium, plotly…)PyPIat their first import
webR (the R interpreter)cdn.basthon.fr or, failing that, webr.r-wasm.orgwhen the R kernel starts
missing R packageswebR's repository (repo.r-wasm.org)at their first library()
inputs (input(), scanf, readline(), prompt…)Basthon's API (api.basthon.fr)at each input

Inputs go through Basthon's API because the kernel, isolated in a worker, cannot receive an answer otherwise while the program waits for it. They are encrypted in the browser (AES-GCM, with a random key that never leaves it): the server only passes on data it cannot read.

Astuce

Not to depend on cdn.basthon.fr for Python, you can serve your own copy of Pyodide: put the version of Pyodide used (the one given by import pyodide; pyodide.__version__), in its full distribution, in the assets/<kernel version>/python3/pyodide/ directory of the installation. The kernel looks for it there first.

What is the latest version of Basthon? ​

To know the latest version of Basthon-Console, see

https://console.basthon.fr/assets/version

Compare this version identifier (kernel-version) with that of your own installation of Basthon-Console (available at the same address) to know whether yours is up to date.

For the notebook, go to

https://notebook.basthon.fr/assets/version

or simply open the Help › About menu.

Info

The news of each version are presented on the blog.