Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import yagmail
|
3 |
+
|
4 |
+
# ์ด๋ฉ์ผ ์ค์
|
5 |
+
SENDER_EMAIL = "[email protected]"
|
6 |
+
APP_PASSWORD = "ctty dyti rfkn zxrt"
|
7 |
+
RECIPIENT_EMAIL = "[email protected]"
|
8 |
+
|
9 |
+
# ์ด๋ฉ์ผ ๋ณด๋ด๋ ํจ์
|
10 |
+
def send_email(subject, content):
|
11 |
+
try:
|
12 |
+
# yagmail SMTP ๊ฐ์ฒด ์์ฑ
|
13 |
+
yag = yagmail.SMTP(SENDER_EMAIL, APP_PASSWORD)
|
14 |
+
|
15 |
+
# ์ด๋ฉ์ผ ๋ณด๋ด๊ธฐ
|
16 |
+
yag.send(
|
17 |
+
to=RECIPIENT_EMAIL,
|
18 |
+
subject=subject,
|
19 |
+
contents=content
|
20 |
+
)
|
21 |
+
|
22 |
+
return "์ด๋ฉ์ผ์ด ์ฑ๊ณต์ ์ผ๋ก ๋ฐ์ก๋์์ต๋๋ค!"
|
23 |
+
except Exception as e:
|
24 |
+
return f"์ด๋ฉ์ผ ๋ฐ์ก ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"
|
25 |
+
|
26 |
+
# Gradio Blocks ์ธํฐํ์ด์ค ์์ฑ
|
27 |
+
with gr.Blocks() as demo:
|
28 |
+
with gr.Row():
|
29 |
+
subject_input = gr.Textbox(label="๋ฉ์ผ ์ ๋ชฉ", placeholder="์ ๋ชฉ์ ์์ฑํ์ธ์.")
|
30 |
+
with gr.Row():
|
31 |
+
body_input = gr.Textbox(label="๋ฉ์ผ ๋ด์ฉ", lines=5, placeholder="์ด๊ณณ์ ๋ฉ์ผ ๋ด์ฉ์ ์์ฑํ์ธ์.")
|
32 |
+
with gr.Row():
|
33 |
+
output = gr.Textbox(label="๊ฒฐ๊ณผ", interactive=False)
|
34 |
+
with gr.Row():
|
35 |
+
button_send = gr.Button("๋ฉ์ผ ๋ฐ์ก") # ๋ฒํผ 1๊ฐ๋ง ํ์
|
36 |
+
|
37 |
+
# ๋ฒํผ ํด๋ฆญ ์ ํจ์ ํธ์ถ
|
38 |
+
button_send.click(fn=send_email, inputs=[subject_input, body_input], outputs=output)
|
39 |
+
|
40 |
+
# Gradio ์ฑ ์คํ
|
41 |
+
demo.launch()
|