Python - Reflex

Reflex is an open-source framework for quickly building beautiful, interactive web applications in pure Python.

Introduction

Reflex is an open-source framework for quickly building beautiful, interactive web applications in pure Python.

Getting Started

Terminal window
uv init app
cd app
uv init reflex

Init the project

Terminal window
uv run reflex init

The command will return several template options to choose from as shown below.

Select “A blank Reflex app”

This will create a directory structure like this:

app
├── .web
├── assets
├── app
│ ├── __init__.py
│ └── app.py
└── rxconfig.py

Initializing your project creates a directory with the same name as your app. This is where you will write your app’s logic.

Reflex generates a default app within the app/app.py file. You can modify this file to customize your app.

Run it in development mode:

Terminal window
uv run reflex run

Your app runs at http://localhost:3000.

Reflex prints logs to the terminal. To increase log verbosity to help with debugging, use the --loglevel flag:

Terminal window
uv run reflex run --loglevel debug

Reflex will hot reload any code changes in real time when running in development mode. Your code edits will show up on http://localhost:3000 automatically.

Counter

Create a simple counter app that lets the user count up or down as explained on Introduction

Basics

Basics

Pending

For a glimpse of the possibilities, check out these resources:

  • For a more real-world example, check out either the dashboard tutorial or the chatapp tutorial.
  • They have bots that can answer questions and generate Reflex code for you.