· 8 years ago · Aug 28, 2018, 05:46 PM
1@app.route('/', methods=['POST', 'GET'])
2def index():
3 conn=sqlite3.connect(":memory:")
4 cur = conn.cursor()
5 sql = "CREATE TABLE if not exists people (id INTEGER, status INTEGER)"
6 cur.execute(sql)
7 if request.method == 'POST':
8 r = request.get_json()
9 chat_id = r['message']['chat']['id']
10 message = r['message']['text']
11 write_json(r)
12 if "/start" in message:
13 send_message(chat_id, text = "Ðу, привет")
14 cur.execute("INSERT INTO people VALUES("+str(chat_id)+", 0)")
15 elif "/db" in message:
16 send_message(chat_id, text = "Второй вопроÑ")
17 [name], = cur.execute("SELECT id FROM people WHERE id=?", (chat_id,))
18 print(name2) # -> a
19 return jsonify(r)
20 print(r);
21 return '<h1>bot welcomes you</h1>'