Browse Source

Update v1.3

master
Evangelos Oulis 5 years ago
parent
commit
ce97baac27
  1. BIN
      serverNode/__pycache__/serv.cpython-37.pyc
  2. 35
      serverNode/serv.py

BIN
serverNode/__pycache__/serv.cpython-37.pyc

Binary file not shown.

35
serverNode/serv.py

@ -23,15 +23,26 @@ sessions = []
# creating an API object
api = Api(app)
# Initialize the database Connection
mydb = mysql.connector.connect(
host = "127.0.0.1",#"q2gen47hi68k1yrb.chr7pe7iynqr.eu-west-1.rds.amazonaws.com",
user = "root",#"zsgmj50h7zgz9ioq",
password = "rootP",#"omk5l1hrwsgvlcez",
database = "PARKING"#"g0s9cnmdkziq6fsp"
)
myCursor = mydb.cursor()
# Initialize the database Connection (Classified)
class mySqlConnect:
def __init__(self):
self.con = con = mysql.connector.connect(
host = "127.0.0.1",#"q2gen47hi68k1yrb.chr7pe7iynqr.eu-west-1.rds.amazonaws.com",
user = "root",#"zsgmj50h7zgz9ioq",
password = "rootP",#"omk5l1hrwsgvlcez",
database = "PARKING"#"g0s9cnmdkziq6fsp"
)
self.cur = self.con.cursor();
def __del__(self):
self.cur.close()
self.con.close()
@property
def cursor(self):
return self.cur
# ==================================
# Define our functions.
@ -40,6 +51,8 @@ myCursor = mydb.cursor()
def getParkings():
parks = []
sql = mySqlConnect()
myCursor = sql.cur
myCursor.execute("SELECT * FROM PARKING")
myRes = myCursor.fetchall()
@ -53,6 +66,9 @@ def getParkings():
# Define a function that get if a user with exiting credencials
# username and password is authenticated.
def isMember(username, password):
mysql = mySqlConnect()
myCursor = mysql.cur
myCursor.execute("SELECT * FROM USERS")
myRes = myCursor.fetchall()
@ -75,7 +91,6 @@ def isAuthenticated(data):
except KeyError as e:
return False
# ==================================================================
# making a class for a particular resource
# the get, post methods correspond to get and post requests
@ -131,6 +146,8 @@ class ParkingStatus(Resource):
thereIs = False
toUpdate = False
mysql = mySqlConnect()
myCursor = mysql.cur
try:
if not thereIs:
# Make a new insert entry for a new Parking Code.

Loading…
Cancel
Save