reflex README

The project's README from github.com/reflex-dev/reflex. As one markdown file: README.md.

Reflex Logo

✨ Performant, customizable web apps in pure Python. Deploy in seconds. ✨

PyPI version versions Documentation PyPI Downloads Discord Twitter


[!NOTE] Build faster with Reflex:


Introduction

Reflex is a library to build full-stack web apps in pure Python.

Key features:

See our architecture page to learn how Reflex works under the hood.

⚙️ Installation

Important: We strongly recommend using a virtual environment to ensure the reflex command is available in your PATH.

🥳 Create your first app

Create a project, add Reflex, and start the development server with uv:

mkdir my_app_name
cd my_app_name
uv init

uv add reflex
uv run reflex init
uv run reflex run

You should see your app running at http://localhost:3000.

Now you can modify the source code in my_app_name/my_app_name.py. Reflex has fast refreshes so you can see your changes instantly when you save your code.

🫧 Example App

Build an image generation app in Python with Reflex: define the UI, manage state in a class, and call an image model from an event handler.

Preview of an image generation app built with Reflex
import reflex as rx
import openai

client = openai.AsyncOpenAI()


class State(rx.State):
    prompt: str = ""
    image_url: str = ""
    processing: bool = False

    @rx.event
    def set_prompt(self, value: str):
        self.prompt = value

    @rx.event
    async def generate(self):
        self.processing = True
        yield
        response = await client.images.generate(
            model="gpt-image-1.5",
            prompt=self.prompt,
        )
        self.image_url = f"data:image/png;base64,{response.data[0].b64_json}"
        self.processing = False


def index():
    return rx.vstack(
        rx.heading("Image Generator"),
        rx.input(placeholder="Enter a prompt...", on_change=State.set_prompt),
        rx.button("Generate", on_click=State.generate, loading=State.processing),
        rx.image(src=State.image_url),
    )


app = rx.App()
app.add_page(index, title="Reflex:Image Generation")

All Thanks To Our Contributors:

reflex (reflex-dev/reflex)

Searching Database…

29K ·GitHub
这是什么?Reflex 是一个用纯 Python 构建全栈 Web 应用的库:前端和后端都用 Python 编写,不需要学 JavaScript。
连前端也是?我完全不用写 JavaScript 吗?不用——纯 Python 就是它最大的卖点:应用的前端和后端全都是用 Python 写的。
我怎么把第一个应用跑起来?在虚拟环境里安装 reflex 包,然后用 uv 创建项目、添加 Reflex 并启动开发服务器——编辑 myappname/myappname.py,改动会通过热刷新立即显示出来。
开始之前需要装好什么?需要 Python 和 reflex 包;README 强烈建议使用虚拟环境,这样 reflex 命令才会在你的 PATH 里可用,官方快速上手用的是 uv。
它是用来做快速原型的,还是也能做复杂、正经的应用?两者都可以:Reflex 上手简单,同时也能扩展到复杂应用,官方还有架构页面解释它底层的运作原理。
用 Reflex 做出来的真实应用长什么样?README 里的示例是一个图片生成应用:你定义界面,用一个 Python 类管理状态,然后在事件处理函数里调用图片模型。
AI Builder 是什么?这是 Reflex 的一项服务,能在几秒钟内生成全栈 Reflex 应用,它和 Agent Toolkit、App Management 一起被列为帮助更快构建应用的工具。
Agent Toolkit 是什么?它把 MCP 和 Skills 接入你的编程助手,让 AI 智能体能够配合 Reflex 工作;而 App Management 则负责部署和管理你的 Reflex 应用。
做完的应用怎么放到网上?README 宣称几秒钟就能完成部署,它的 App Management 服务可以部署并管理你的 Reflex 应用。
What are similar projects?wasp, nuxt, router, django, elpis, datapages, streamlit, gin-vue-admin
Creator
reflex-dev
Size
196.3 MB
Stars
29K
Age
3y
Commits · 90 Days