# Mesop

> Build web apps and AI demos in pure Python, no JavaScript or CSS required

- Category: App UIs & Builders / Data App Builders
- Language: Python
- Repository: https://github.com/mesop-dev/mesop
- Website: https://google.github.io/mesop
- Canonical page: https://ai-tldr.dev/tools/mesop/

## In short

Mesop is a Python-based UI framework, started at Google, for quickly building web apps such as demos and internal tools. You write the interface in plain Python using a reactive model, so you don't need to write JavaScript, CSS, or HTML. It sits in the Data App Builders category of the App UIs & Builders tools and is open-source, written in Python.

## Overview

Mesop is a Python-based UI framework, started at Google, for quickly building web apps such as demos and internal tools. You write the interface in plain Python using a reactive model, so you don't need to write JavaScript, CSS, or HTML.

It is aimed at developers who are comfortable in Python but are not front-end specialists. You compose your UI from ready-made components and your own Python functions, and the framework handles rendering in the browser.

Within the data-app builder category, Mesop fits the case where you want to stand up an AI demo or internal app fast, with hot reload and IDE type safety, while staying entirely in Python.

## What it does

- Write UI in idiomatic Python with a reactive paradigm, no JavaScript, CSS, or HTML needed
- Ready-to-use components plus the ability to compose your own UI from plain Python functions
- Hot reload that automatically refreshes the browser and preserves app state
- Strong type safety and rich IDE support
- Labs helpers like text_to_text for quickly wiring up AI demo interfaces
- Try it instantly in a hosted Colab notebook before installing locally

## Getting started

You can write a first Mesop app in fewer than 10 lines of Python. Install the package, drop in the example, and run it.

1. Install Mesop

   Install the package from PyPI.

```bash
pip install mesop
```

2. Create main.py

   Copy this example into a file named main.py. It defines a page and a simple text-to-text handler.

```python
import mesop as me
import mesop.labs as mel

@me.page(path="/text_to_text", title="Text to Text Example")
def app():
  mel.text_to_text(
    upper_case_stream,
    title="Text to Text Example",
  )

def upper_case_stream(s: str):
  return "Echo: " + s.capitalize()
```

3. Run the app

   Start the dev server with the mesop CLI and open it in your browser.

```bash
mesop main.py
```

## When to use it

- Building an internal web app for a team without bringing in a front-end stack
- Standing up a quick AI demo with a text input and output
- Prototyping a UI in Python with hot reload during development
- Sharing a runnable interface for a model or script via a hosted Colab notebook
