File size: 1,177 Bytes
0a3635f
 
 
 
 
 
12581a3
0a3635f
 
 
 
 
 
 
12581a3
0a3635f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12581a3
0a3635f
 
12581a3
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
import hashlib
import time
from flask import Flask, render_template, request, jsonify

app = Flask(__name__)
current_text = ""
logs = []

def get_ip_hash(ip):
    return hashlib.sha256(ip.encode()).hexdigest()[:8]

def log_text(ip, text):
    timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
    ip_hash = get_ip_hash(ip)
    logs.append([timestamp, ip_hash, text])

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/ViewPort')
def viewport():
    return render_template('viewport.html')

@app.route('/Ctrl', methods=['GET', 'POST'])
def ctrl():
    global current_text
    if request.method == 'POST':
        new_text = request.form['text']
        if new_text != current_text:  # Check for duplicate content
            current_text = new_text
            log_text(request.remote_addr, current_text)
        return '', 204
    return render_template('ctrl.html')

@app.route('/get_text')
def get_text():
    global current_text
    return jsonify({'text': current_text})

@app.route('/log')
def log():
    return render_template('log.html', log_data=logs)

if __name__ == '__main__':
    app.run(debug=True, host="0.0.0.0")