-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·57 lines (45 loc) · 1.19 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
from packet_mapper import PacketsMapper
from flask import Flask, send_from_directory
import requests
import json
import sys
import logging
app = Flask(__name__)
log = logging.getLogger('werkzeug')
log.disabled = True
app.logger.disabled = True
queue = []
@app.route('/')
def index():
return send_from_directory('pages','index.html')
@app.route("/pkt")
def send_pkt():
global queue
if queue:
data=queue.pop(0)
print(f"\r{len(queue)} packets in queue",end="\r")
return data
else:
return {}
mapper = None
@app.route("/mydata")
def send_mydata():
return mapper.get_my_location()
@app.route('/static-files/<path:path>')
def static_files(path):
return send_from_directory('static',path)
def callback(data):
global queue
MAX_PACKETS = 500 #you can change it, my advice, *!DON'T!*
if len(queue) < MAX_PACKETS:
queue.append(data)
print(f"\r{len(queue)} packets in queue",end="\r")
def main():
global mapper
print("Welcome to packets mapping server!!")
mapper = PacketsMapper(callback,useProxy=False,threaded=True)
mapper.start()
app.run()
if __name__ == "__main__":
main()