-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (45 loc) · 1.66 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
58
import sys
from PyQt6.QtWidgets import QApplication, QMainWindow, QStatusBar
from main_ui import *
from request_handler import RequestHandler
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.httpMethods = [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS"
]
self.ui.methodsComboBox.addItems(self.httpMethods)
self.statusBar = QStatusBar()
self.setStatusBar(self.statusBar)
# Connections
self.ui.methodsComboBox.currentIndexChanged.connect(self.updateHttpMethod)
self.ui.sendRequestPushButton.clicked.connect(self.sendRequest)
self.show()
def updateHttpMethod(self):
print(self.httpMethods[self.ui.methodsComboBox.currentIndex()])
def sendRequest(self):
# print(self.ui.urlInput.text)
if self.ui.urlInput.text() == "":
self.statusBar.showMessage("URL text box is empty.",2000)
else:
response_type, response_content = RequestHandler(self.ui.urlInput.text(), method=self.ui.methodsComboBox.currentText()).send()
if response_type == "json":
print(response_content)
self.ui.outputTextEdit.setText(str(response_content))
if response_type == "html":
print(response_content)
self.ui.outputTextEdit.setText(response_content)
def updateOutput(self):
pass
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
sys.exit(app.exec())