-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (27 loc) · 905 Bytes
/
app.py
File metadata and controls
31 lines (27 loc) · 905 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
30
31
from flask import Flask, request, abort
import random
import threading
import time
app = Flask(__name__)
whitelisted_ips =['192.168.25.48','192.168.25.61','192.168.234.243'] # Example list of whitelisted IPs
current_sequence = ""
def generate_sequence():
global current_sequence
while True:
sequence = ''.join(random.choices("1234567890ABCD", k=7))
with open("otp.txt", "w") as f:
f.write(sequence)
f.close()
current_sequence = sequence
time.sleep(30)
@app.route('/')
def get_sequence():
s='access denied'
client_ip = request.remote_addr
print(client_ip)
if client_ip not in whitelisted_ips:
return s # Access Denied
return current_sequence
if __name__ == '__main__':
threading.Thread(target=generate_sequence, daemon=True).start()
app.run(host='0.0.0.0', port=5000, debug=True) # Run the Flask app