-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (37 loc) · 1.03 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
from PyQt6 import QtWidgets, uic, QtCore, QtGui
import sys, requests, os
# from time import sleep
class Ui(QtWidgets.QDialog):
'''UI functions of Visca Image Editor'''
def __init__(self):
super(Ui, self).__init__()
uic.loadUi(os.path.join("UI", "login.ui"), self)
self.setWindowTitle("Visca Login")
self.loginButton.clicked.connect(self.login)
def login(self):
'''Login logic'''
response = None
username = str(self.usernameInput.text())
passwd = str(self.passwordInput.text())
payload = {"username": username, "pass": passwd}
try:
r = requests.post("http://127.0.0.1:5656/auth", data = payload)
except:
print("Network error")
else:
response = r.text
if response == "alwd":
from visca import Visca
box = Visca()
box.show()
self.hide()
print("Allowed")
elif response == "acnf":
self.notif.setText("Incorrect username or password.")
else:
self.notif.setText("Some error ocurred.")
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = Ui()
window.show()
app.exec()