Major performance increase

main
Gabriel 2 years ago
parent ca4b7635a4
commit b294032487

@ -3,8 +3,6 @@
display: flex;
flex-direction: column;
align-items: center;
margin-left:5vw;
margin-right:5vw;
}
#interverse-details{
@ -223,26 +221,9 @@ a{
Alpine.store("data", {});
interverse_data(url.replace("https://",'').replace('http://','').replace('/',''), function (data) {
console.log("Initializing interverse...")
Alpine.store('data',data);
for (group in data['connection_groups']) {
for (link in data['connection_groups'][group]) {
url = data['connection_groups'][group][link];
console.log("Connection: "+url)
interverse_data(url.replace("https://",'').replace('http://','').replace('/',''),function(data){
Alpine.store(data['location'],data)
});
//connections.push(data['connection_groups'][group][link]);
}
}
var connections = data['connections'];
for (var i = 0; i < connections.length; i++) {
url = connections[i].replace("https://",'').replace('http://','').replace('/','')
interverse_data(url,function(data){
if (data['location']){
Alpine.store(data['location'],data);
}
});
Alpine.store('data',data['main'])
for (c in data['connections']){
Alpine.store(c,data['connections'][c])
}
});

@ -7,15 +7,13 @@ import simple_cache
app = Flask('interverse-proxy')
cache = simple_cache.Cache()
@app.route("/", methods=['GET'])
def interverse_proxy():
url = request.args.get('url')
if url == None:
return redirect("https://codeberg.org/gabe/Interverse",307)
return "See <a href='https://codeberg.org/gabe/Interverse'>Interverse</a>"
data = cache.load_data(url)
data = cache.get_interverse_data(url)
return json.dumps(data)
if __name__ == '__main__':

@ -60,3 +60,25 @@ class Cache:
'time':t+ideal_delta
}
return data
def get_interverse_data(self,url):
origin = self.load_data(url)
connections = {}
for con in origin['connections']:
dat = self.load_data(con.replace('https://','').replace('http://','').replace("/",''))
if dat != None:
connections[con] = dat
for g in origin['connection_groups']:
for con in origin['connection_groups'][g]:
dat = self.load_data(con.replace('https://','').replace('http://','').replace("/",''))
if dat != None:
connections[con] = dat
return {
'main':origin,
'connections':connections
}
if __name__ == '__main__':
c = Cache()

Loading…
Cancel
Save