Fixed weird timeout issue

This commit is contained in:
30hours 2024-02-27 01:49:10 +00:00
parent 7621c04949
commit b558ac3d4e
6 changed files with 23 additions and 12 deletions

View file

@ -60,10 +60,11 @@ def serve_static(file):
@app.route("/api")
def api():
api = request.query_string.decode('utf-8')
try:
reply = message_api_request.send_message(api)
except Exception as e:
reply = "Exception: " + str(e)
print(reply, flush=True)
urls = request.args.getlist("url")
data = [{"url": 'http://' + url} for url in urls]
return reply
@app.route("/map/<path:file>")

View file

@ -1,7 +1,7 @@
function event_radar() {
radar_url = window.location.origin + '/api' + window.location.search;
console.log(radar_url);
var radar_url = window.location.origin +
'/api' + window.location.search;
fetch(radar_url)
.then(response => {
@ -11,8 +11,15 @@ function event_radar() {
return response.json();
})
.then(data => {
// Update aircraft points based on new data
console.log("test");
for (const key in data["detections_localised"]) {
if (data["detections_localised"].hasOwnProperty(key)) {
const target = data["detections_localised"][key];
const points = target["points"];
console.log(points);
}
}
})
.catch(error => {
// Handle errors during fetch

View file

@ -184,7 +184,7 @@ window.addEventListener('load', function () {
// add radar points
const radar_names = new URLSearchParams(
window.location.search).getAll('url');
window.location.search).getAll('server');
console.log(radar_names);
var radar_config_url = radar_names.map(
url => `http://${url}/api/config`);

View file

@ -45,7 +45,7 @@ document.getElementById('buttonMap').addEventListener('click', function() {
var adsb = document.querySelector('[name="adsb"]').value;
// Construct the URL with the form values
var apiUrl = '?url=' + Array.from(servers).map(server => server.value).join('&url=');
var apiUrl = '?server=' + Array.from(servers).map(server => server.value).join('&server=');
var mapUrl = '/map/index.html' + apiUrl + '&associator=' + associator + '&coordreg=' + coordreg + '&adsb=' + adsb;
// Redirect to the constructed URL

View file

@ -58,7 +58,7 @@ class Message:
with conn:
while True:
data = conn.recv(65000)
data = conn.recv(8096)
if not data:
break
decoded_data = data.decode()
@ -82,7 +82,7 @@ class Message:
try:
client_socket.connect((self.host, self.port))
client_socket.sendall(message.encode())
reply = client_socket.recv(65000).decode()
reply = client_socket.recv(8096).decode()
return reply
except ConnectionRefusedError:
print(f"Connection to {self.host}:{self.port} refused.")

View file

@ -181,7 +181,10 @@ async def callback_message_received(msg):
api[-1]["server"] = [api[-1]["server"]]
# json dump
output = json.dumps(api)
for item in api:
if item["hash"] == short_hash(msg):
output = json.dumps(item)
break
return output