-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeep_alive.py
More file actions
125 lines (97 loc) · 2.89 KB
/
keep_alive.py
File metadata and controls
125 lines (97 loc) · 2.89 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
from flask import Flask, render_template, request, abort
from threading import Thread
import sqlite3
import sys
app = Flask(__name__)
con = sqlite3.connect('tinker.db')
print("Opened database successfully")
con.execute("""CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user TEXT,
user_id INTEGER UNIQUE);""")
print("Table created successfully")
con.close()
@app.route('/')
def home():
return render_template('user.html')
@app.route('/webhook', methods = ['POST'])
def webhook():
print("Recieved Webhook")
sys.stdout.flush()
if request.method == 'POST':
print(request.json)
return 'Success', 200
else:
abort(400)
@app.route('/newuser')
def new_user():
return render_template('home.html')
@app.route('/stats')
def stats():
return render_template('stats.html')
@app.route('/addrec', methods = ['POST','GET'])
def addrec():
if request.method == 'POST':
try:
dn = request.form['dn']
di = request.form['di']
with sqlite3.connect("tinker.db") as con:
cur = con.cursor()
cur.execute("INSERT INTO users (user, user_id) VALUES (?,?)",(dn, di) )
con.commit()
msg = "Record successfully added"
print(msg)
except:
con.rollback()
msg = "error in insert operation"
finally:
if di == '425477636333240331':
con.close()
return render_template("result.html", msg = msg)
if ((not dn) or (not di)):
msg = "Please fill the required fields"
return render_template("user.html", msg = msg)
else:
con.close()
return render_template("thx.html", msg = msg)
else:
return render_template("user.html")
@app.route('/list')
def list():
con = sqlite3.connect("tinker.db")
con.row_factory = sqlite3.Row
cur = con.cursor()
cur.execute("select * from users")
rows = cur.fetchall();
return render_template("list.html",rows = rows)
@app.route('/doc')
def help_list():
return render_template('documentation/docs.html')
@app.route('/rps')
def rps():
return render_template('documentation/rps.html')
@app.route('/support')
def support():
return render_template('documentation/support.html')
@app.route('/donate')
def donate():
return render_template('documentation/donate.html')
@app.route('/don')
def don():
return render_template('documentation/don.html')
@app.route('/work')
def work():
return render_template('documentation/work.html')
@app.route('/vote')
def vote():
return render_template('documentation/vote.html')
@app.route('/youtube')
def youtube():
return render_template('documentation/youtube.html')
if __name__ == "__main__":
app.run(debug=True)
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()