-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeep_alive.py
44 lines (36 loc) · 1005 Bytes
/
keep_alive.py
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
# keep alive server => uptimerobot
from flask import Flask, render_template, jsonify
from threading import Thread
import json
app = Flask('')
@app.route('/')
def home():
return "Web-server for xtweet bot is online"
@app.route('/logs')
def logs():
# display logs
try:
with open('.logs.txt', 'r') as file:
data = file.read().strip()
except Exception as err:
data = f"[error] {str(err)}"
return render_template(
'logs.html',
content = data
)
@app.route('/users_info')
def users_info():
try:
with open('.users.json', 'r') as json_file:
data = json.load(json_file)
prettified_data = json.dumps(data, indent=4)
return jsonify(prettified_data)
except FileNotFoundError:
return "File not found", 404
except Exception as err:
return f"[error] {str(err)}", 500
def run():
app.run(host='0.0.0.0', port=8000)
def keep_alive():
t = Thread(target=run)
t.start()