forked from boterostg/botBasicoGlitch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
29 lines (22 loc) · 723 Bytes
/
server.py
File metadata and controls
29 lines (22 loc) · 723 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
import flask, telebot
from bot import bot
app = flask.Flask(__name__)
WEBHOOK_URL_PATH = "/{}".format(bot.token)
index = open('static/index.html').read()
# Process index page
@app.route('/')
def root():
print('index!')
return index # 'xd' # flask.send_from_directory('/static', 'index.html')
# Process webhook calls
@app.route(WEBHOOK_URL_PATH, methods=['POST'])
def webhook():
if flask.request.headers.get('content-type') == 'application/json':
json_string = flask.request.get_data().decode('utf-8')
update = telebot.types.Update.de_json(json_string)
bot.process_new_updates([update])
return ''
else:
flask.abort(403)
if __name__ == "__main__":
app.run()