-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.py
More file actions
90 lines (64 loc) · 2.75 KB
/
Controller.py
File metadata and controls
90 lines (64 loc) · 2.75 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!C:\Python\python.exe
print("Content-Type: text/html")
print()
import cgi
import sys
form = cgi.FieldStorage()
# so these are data we posted from index
getALL = form.getvalue("ALL")
searchVisitorID = form.getvalue("visitor_id")
clearDatabase = form.getvalue("clear")
clearSearch = form.getvalue("clear_search")
postedVisitorID = form.getvalue("visitor_ID")
postedTime = form.getvalue("time")
postedDate = form.getvalue("date")
if str(getALL) != "None":
# controller asks model to show all records
sys.path.append("C:/xampp/htdocs/laser-visitor-counter-IoT-NodeMCU-RFID/MVC/model")
from Queries import MyQuery1
query1 = MyQuery1()
results = query1.showAll()
# controller updates the view of data obtained from the model
sys.path.append("C:/xampp/htdocs/laser-visitor-counter-IoT-NodeMCU-RFID/MVC/view")
from DisplayData import MyView1
view1 = MyView1(results)
view1.viewAll()
if str(searchVisitorID) != "None":
# controller asks model to show all records
sys.path.append("C:/xampp/htdocs/laser-visitor-counter-IoT-NodeMCU-RFID/MVC/model")
from Queries import MyQuery2
query2 = MyQuery2(searchVisitorID)
results = query2.searchN()
# controller updates the view of data obtained from the model
sys.path.append("C:/xampp/htdocs/laser-visitor-counter-IoT-NodeMCU-RFID/MVC/view")
from DisplayData import MyView2
view1 = MyView2(results)
view1.viewSearched()
elif str(clearSearch) != "None":
# controller asks model to show all records
sys.path.append("C:/xampp/htdocs/laser-visitor-counter-IoT-NodeMCU-RFID/MVC/model")
from Queries import MyQuery1
query1 = MyQuery1()
results = query1.showAll()
# controller updates the view of data obtained from the model
sys.path.append("C:/xampp/htdocs/laser-visitor-counter-IoT-NodeMCU-RFID/MVC/view")
from DisplayData import MyView1
view1 = MyView1(results)
view1.viewAll()
if str(clearDatabase) != "None":
# controller asks model to clear the database
sys.path.append("C:/xampp/htdocs/laser-visitor-counter-IoT-NodeMCU-RFID/MVC/model")
from Queries import MyClearDatabase
clear_db = MyClearDatabase()
result = clear_db.clearAll()
print(result)
# controller updates the view back to show all records
sys.path.append("C:/xampp/htdocs/laser-visitor-counter-IoT-NodeMCU-RFID/MVC/model")
from Queries import MyQuery1
query1 = MyQuery1()
results = query1.showAll()
# controller updates the view of data obtained from the model
sys.path.append("C:/xampp/htdocs/laser-visitor-counter-IoT-NodeMCU-RFID/MVC/view")
from DisplayData import MyView1
view1 = MyView1(results)
view1.viewAll()