-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (24 loc) · 946 Bytes
/
app.py
File metadata and controls
33 lines (24 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# TELEGRAM_BOT_TOKEN = '6384605708:AAEzqbyJnXu0yAdNFZvUBaK8fcpTEvseuNo'
# TELEGRAM_CHAT_ID = '71046013'
from flask import Flask, render_template, request
import telepot
app = Flask(__name__)
app.debug = True
TELEGRAM_BOT_TOKEN = '6384605708:AAEzqbyJnXu0yAdNFZvUBaK8fcpTEvseuNo'
TELEGRAM_CHAT_ID = '71046013'
@app.route('/')
def home():
return render_template('report.html')
@app.route('/submit', methods=['POST'])
def submit():
reporter = request.form['reporter']
location = request.form['location']
complaint = request.form['complaint']
message = f'신고자: {reporter}\n위치: {location}\n불편내용: {complaint}'
send_telegram_message(message)
return '신고가 접수되었습니다. 감사합니다!'
def send_telegram_message(message):
bot = telepot.Bot(TELEGRAM_BOT_TOKEN)
bot.sendMessage(TELEGRAM_CHAT_ID, message)
if __name__ == '__main__':
app.run()