diff --git a/docs/zh/zh_tw/README.md b/docs/zh/zh_tw/README.md index 76839ebc2..f089825dd 100644 --- a/docs/zh/zh_tw/README.md +++ b/docs/zh/zh_tw/README.md @@ -15,11 +15,26 @@  [](https://reflex.dev/docs/getting-started/introduction) [](https://discord.gg/T5WSbC2YtQ) + --- -[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) + +[English](https://github.com/reflex-dev/reflex/blob/main/README.md) | [简体中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_cn/README.md) | [繁體中文](https://github.com/reflex-dev/reflex/blob/main/docs/zh/zh_tw/README.md) | [Türkçe](https://github.com/reflex-dev/reflex/blob/main/docs/tr/README.md) | [हिंदी](https://github.com/reflex-dev/reflex/blob/main/docs/in/README.md) | [Português (Brasil)](https://github.com/reflex-dev/reflex/blob/main/docs/pt/pt_br/README.md) | [Italiano](https://github.com/reflex-dev/reflex/blob/main/docs/it/README.md) | [Español](https://github.com/reflex-dev/reflex/blob/main/docs/es/README.md) | [한국어](https://github.com/reflex-dev/reflex/blob/main/docs/kr/README.md) | [日本語](https://github.com/reflex-dev/reflex/blob/main/docs/ja/README.md) + --- + +# Reflex + +Reflex 是一個可以用純 Python 構建全端網頁應用程式的函式庫。 + +主要特色: + +* **純 Python** - 您可以用 Python 撰寫應用程式的前端和後端,無需學習 Javascript。 +* **完全靈活性** - Reflex 易於上手,但也可以擴展到複雜的應用程式。 +* **立即部署** - 構建後,只需使用[單一指令](https://reflex.dev/docs/hosting/deploy-quick-start/)即可部署您的應用程式,或在您自己的伺服器上託管。 +請參閱我們的[架構頁面](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture)了解 Reflex 如何在底層運作。 + ## ⚙️ 安裝 開啟一個終端機並且執行 (需要 Python 3.8+): @@ -70,7 +85,8 @@ reflex run import reflex as rx import openai -openai.api_key = "YOUR_API_KEY" +openai_client = openai.OpenAI() + class State(rx.State): """應用程式狀態""" @@ -86,33 +102,33 @@ class State(rx.State): self.processing, self.complete = True, False yield - response = openai.Image.create(prompt=self.prompt, n=1, size="1024x1024") - self.image_url = response["data"][0]["url"] + response = openai_client.images.generate( + prompt=self.prompt, n=1, size="1024x1024" + ) + self.image_url = response.data[0].url self.processing, self.complete = False, True def index(): return rx.center( rx.vstack( - rx.heading("DALL·E"), - rx.input(placeholder="Enter a prompt", on_blur=State.set_prompt), + rx.heading("DALL-E", font_size="1.5em"), + rx.input( + placeholder="Enter a prompt..", + on_blur=State.set_prompt, + width="25em", + ), rx.button( - "Generate Image", + "Generate Image", on_click=State.get_image, - is_loading=State.processing, - width="100%", + width="25em", + loading=State.processing ), rx.cond( State.complete, - rx.image( - src=State.image_url, - height="25em", - width="25em", - ) + rx.image(src=State.image_url, width="20em"), ), - padding="2em", - shadow="lg", - border_radius="lg", + align="center", ), width="100%", height="100vh", @@ -120,10 +136,22 @@ def index(): # 把狀態跟頁面添加到應用程式。 app = rx.App() -app.add_page(index, title="reflex:DALL·E") +app.add_page(index, title="Reflex:DALL-E") ``` + + + + + + ## 讓我們來拆解一下。 + +