fdfdfef / app.py
aiqtech's picture
Update app.py
5d67131 verified
raw
history blame
1.46 kB
from flask import Flask, request, render_template_string
import requests
import json
app = Flask(__name__)
# HTML ํ…œํ”Œ๋ฆฟ
HTML_TEMPLATE = '''
<!DOCTYPE html>
<html>
<head>
<title>์ด๋ฉ”์ผ ์ „์†ก</title>
<meta charset="utf-8">
</head>
<body>
<h1>์ด๋ฉ”์ผ ์›นํ›… ์ „์†ก</h1>
<form method="POST">
<input type="email" name="email" placeholder="์ด๋ฉ”์ผ ์ฃผ์†Œ ์ž…๋ ฅ" required>
<input type="submit" value="์ „์†ก">
</form>
{% if result %}
<p>{{ result }}</p>
{% endif %}
</body>
</html>
'''
@app.route('/', methods=['GET', 'POST'])
def home():
result = None
if request.method == 'POST':
email = request.form['email']
webhook_url = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjYwNTZmMDYzMDA0M2M1MjZiNTUzMzUxMzUi_pc"
try:
response = requests.post(webhook_url, json={"email": email})
if response.status_code == 200:
try:
result = f"์„ฑ๊ณต!\n{json.dumps(response.json(), indent=2, ensure_ascii=False)}"
except:
result = f"์„ฑ๊ณต!\n{response.text}"
else:
result = f"์˜ค๋ฅ˜: {response.status_code}\n{response.text}"
except Exception as e:
result = f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
return render_template_string(HTML_TEMPLATE, result=result)
if __name__ == '__main__':
app.run(debug=True, port=7860)