Update app.py
Browse files
app.py
CHANGED
@@ -1,83 +1,50 @@
|
|
1 |
-
from
|
2 |
-
from fastapi.responses import HTMLResponse
|
3 |
import requests
|
4 |
import json
|
5 |
-
import uvicorn
|
6 |
|
7 |
-
app =
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
<
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
<button type="submit">์ ์ก</button>
|
30 |
-
</form>
|
31 |
-
<div id="result"></div>
|
32 |
-
</div>
|
33 |
-
<script>
|
34 |
-
document.getElementById('emailForm').addEventListener('submit', async (e) => {
|
35 |
-
e.preventDefault();
|
36 |
-
const email = document.getElementById('email').value;
|
37 |
-
const resultDiv = document.getElementById('result');
|
38 |
-
|
39 |
-
try {
|
40 |
-
const response = await fetch('/send-email', {
|
41 |
-
method: 'POST',
|
42 |
-
headers: {
|
43 |
-
'Content-Type': 'application/x-www-form-urlencoded',
|
44 |
-
},
|
45 |
-
body: `email=${encodeURIComponent(email)}`
|
46 |
-
});
|
47 |
-
|
48 |
-
const result = await response.text();
|
49 |
-
resultDiv.textContent = result;
|
50 |
-
} catch (error) {
|
51 |
-
resultDiv.textContent = `์ค๋ฅ ๋ฐ์: ${error.message}`;
|
52 |
-
}
|
53 |
-
});
|
54 |
-
</script>
|
55 |
-
</body>
|
56 |
-
</html>
|
57 |
-
"""
|
58 |
|
59 |
-
@app.
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
"
|
65 |
-
}
|
66 |
-
|
67 |
-
try:
|
68 |
-
response = requests.post(webhook_url, json=payload)
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
81 |
|
82 |
-
if __name__ ==
|
83 |
-
|
|
|
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)
|