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