yoon2566 commited on
Commit
34c5273
ยท
verified ยท
1 Parent(s): 4d4148e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
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()