Special issue: Build stateful web pages with Python

As a data scientist, you can do a lot with Python: train models, build servers, write scripts. Now, in the Baseten app builder, you can do something special with Python: build dynamic front-end web interactions that run in the browser.

âś•
The Python code in this screenshot runs directly on the end user's browser

JavaScript’s claim to fame is that it is the language of the web browser. But building a dynamic front-end experience shouldn’t require learning a new programming language. So we now support Python as the default way to write front-end functions in the view builder. JavaScript is still supported as well.

Before, with Javascript:

let nums = [1, 2, 3, 4, 5]
let evens = nums.filter(function (num) {
  return (num % 2 == 0);
});
return evens

Now, with Python:

nums = [1, 2, 3, 4, 5]
return [n for n in nums if n % 2 == 0]

Python in the view builder isn’t just for basic operations. You can import many packages, including all Python built-in packages and popular data science libraries like numpy. Unfortunately, due to limitations in the technology powering Python in the web browser, you can’t install your own packages like you can in the back end.

âś•
A screenshot of an app build with Python in the view builder

To help you get started with this exciting new capability, we prepared a tutorial on building a stateful web app with Python in the view builder. Follow along to build an auto loan payoff calculator in fifteen minutes using drag and drop components, state, and a Python function. Read the tutorial here.