aiqtech commited on
Commit
6a8c09b
ยท
verified ยท
1 Parent(s): eb3d23a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -45
app.py CHANGED
@@ -1,50 +1,26 @@
1
- from flask import Flask, request, render_template_string
2
  import requests
3
- import json
4
 
5
- app = Flask(__name__)
 
 
6
 
7
- # HTML ํ…œํ”Œ๋ฆฟ
8
- HTML_TEMPLATE = '''
9
- <!DOCTYPE html>
10
- <html>
11
- <head>
12
- <title>์ด๋ฉ”์ผ ์ „์†ก</title>
13
- <meta charset="utf-8">
14
- </head>
15
- <body>
16
- <h1>์ด๋ฉ”์ผ ์›นํ›… ์ „์†ก</h1>
17
- <form method="POST">
18
- <input type="email" name="email" placeholder="์ด๋ฉ”์ผ ์ฃผ์†Œ ์ž…๋ ฅ" required>
19
- <input type="submit" value="์ „์†ก">
20
- </form>
21
- {% if result %}
22
- <p>{{ result }}</p>
23
- {% endif %}
24
- </body>
25
- </html>
26
- '''
27
 
28
- @app.route('/', methods=['GET', 'POST'])
29
- def home():
30
- result = None
31
- if request.method == 'POST':
32
- email = request.form['email']
33
- webhook_url = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjYwNTZmMDYzMDA0M2M1MjZiNTUzMzUxMzUi_pc"
34
-
35
- try:
36
- response = requests.post(webhook_url, json={"email": email})
37
- if response.status_code == 200:
38
- try:
39
- result = f"์„ฑ๊ณต!\n{json.dumps(response.json(), indent=2, ensure_ascii=False)}"
40
- except:
41
- result = f"์„ฑ๊ณต!\n{response.text}"
42
- else:
43
- result = f"์˜ค๋ฅ˜: {response.status_code}\n{response.text}"
44
- except Exception as e:
45
- result = f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
46
-
47
- return render_template_string(HTML_TEMPLATE, result=result)
48
 
49
- if __name__ == '__main__':
50
- app.run(debug=True, port=7860)
 
 
1
+ import gradio as gr
2
  import requests
 
3
 
4
+ def send_webhook(email):
5
+ webhook_url = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjYwNTZmMDYzMDA0M2M1MjZiNTUzMzUxMzUi_pc"
6
+ payload = {"email": email}
7
 
8
+ try:
9
+ response = requests.post(webhook_url, json=payload)
10
+ return f"์‘๋‹ต ์ฝ”๋“œ: {response.status_code}\n์‘๋‹ต ๋‚ด์šฉ: {response.text}"
11
+ except Exception as e:
12
+ return f"์—๋Ÿฌ ๋ฐœ์ƒ: {str(e)}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ # ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ
15
+ demo = gr.Interface(
16
+ fn=send_webhook,
17
+ inputs=gr.Textbox(label="์ด๋ฉ”์ผ ์ฃผ์†Œ", placeholder="์ด๋ฉ”์ผ์„ ์ž…๋ ฅํ•˜์„ธ์š”"),
18
+ outputs=gr.Textbox(label="๊ฒฐ๊ณผ"),
19
+ title="์ด๋ฉ”์ผ ์›นํ›… ์ „์†ก",
20
+ description="์ž…๋ ฅํ•œ ์ด๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ์›นํ›…์œผ๋กœ ์ „์†กํ•ฉ๋‹ˆ๋‹ค.",
21
+ live=False
22
+ )
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ # ์•ฑ ์‹คํ–‰
25
+ if __name__ == "__main__":
26
+ demo.queue().launch(share=False, server_port=7860)