fixed connection on showcase screen

This commit is contained in:
janis
2022-10-31 19:10:39 +01:00
parent 16601a9928
commit 27caf79371
5 changed files with 25 additions and 16 deletions

View File

@@ -3,18 +3,21 @@ import requests
class Com:
def __init__(self):
pass
self.connectok = True
def connect(self, url):
try:
self.x = requests.get(f"{url}/tryconnect")
except Exception:
self.connectok = False
return False
print(self.x.text)
if self.x.text == "ok":
return True
if self.connectok:
if self.x.text == "ok":
return True
else:
return False
else:
return False
pass
def getcurrentsong(self, url):
try:

View File

@@ -21,6 +21,7 @@ class ConnectionPU(Popup):
class LoginWindow(MDScreen):
def connect(self):
global address
self.url = self.ids.url.text
self.containsPort = False
for self.letter in self.url:
@@ -31,15 +32,20 @@ class LoginWindow(MDScreen):
self.connectionurl = ""
if self.url[:8] != "https://" and self.url[:7] != "http://" and self.url[len(self.url) - 1:] == "/" and not self.containsPort and len(self.url) > 2:
self.connectionurl = f"http://{self.url[:len(self.url) - 1]}:8000"
print(comHandler.connect(self.connectionurl))
if comHandler.connect(self.connectionurl):
address = self.connectionurl
screen_manager.current = "ShowcaseScreen"
else:
ConnectionPU().open()
elif self.url[:8] != "https://" and self.url[:7] != "http://" and self.url[len(self.url) - 1:] != "/" and not self.containsPort and len(self.url) > 2:
self.connectionurl = f"http://{self.url}:8000"
print(comHandler.connect(self.connectionurl))
if comHandler.connect(self.connectionurl):
address = self.connectionurl
screen_manager.current = "ShowcaseScreen"
else:
ConnectionPU().open()
else:
ConnectionPU().open()
global address
address = self.connectionurl
screen_manager.current = "ShowcaseScreen"
ConnectionPU().open()
class ShowcaseScreen(MDScreen):