|
|
@ -1,7 +1,7 @@ |
|
|
|
#Authors: Oulis Evangelos, Oulis Nikolaos, Drosos Katsibras |
|
|
|
#=================================================================== |
|
|
|
# using flask restful |
|
|
|
from flask import Flask, request, jsonify |
|
|
|
from flask import Flask, request, jsonify, session |
|
|
|
from flask_restful import Resource, Api |
|
|
|
from json import dumps |
|
|
|
import json |
|
|
@ -20,10 +20,10 @@ api = Api(app) |
|
|
|
|
|
|
|
# Initialize the database Connection |
|
|
|
mydb = mysql.connector.connect( |
|
|
|
host = "q2gen47hi68k1yrb.chr7pe7iynqr.eu-west-1.rds.amazonaws.com", |
|
|
|
user = "zsgmj50h7zgz9ioq", |
|
|
|
password = "omk5l1hrwsgvlcez", |
|
|
|
database = "g0s9cnmdkziq6fsp" |
|
|
|
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() |
|
|
@ -45,6 +45,19 @@ def getParkings(): |
|
|
|
parks.append({"no": res[0], "status": False}) |
|
|
|
return parks |
|
|
|
|
|
|
|
def isMember(username, password): |
|
|
|
myCursor.execute("SELECT * FROM USERS") |
|
|
|
myRes = myCursor.fetchall() |
|
|
|
|
|
|
|
isValid = False |
|
|
|
for res in myRes: |
|
|
|
if res[1] == username and res[2] == password: |
|
|
|
isValid = True |
|
|
|
break |
|
|
|
|
|
|
|
return isValid |
|
|
|
|
|
|
|
|
|
|
|
# ================================================================== |
|
|
|
# making a class for a particular resource |
|
|
|
# the get, post methods correspond to get and post requests |
|
|
@ -115,8 +128,8 @@ api.add_resource(ParkingStatus, '/parkingStatus') |
|
|
|
if __name__ == '__main__': |
|
|
|
app.run( |
|
|
|
debug=True, |
|
|
|
host=app.config.get("HOST", "0.0.0.0"), |
|
|
|
port=app.config.get("PORT", "5000") |
|
|
|
host=app.config.get("HOST", "localhost"), |
|
|
|
port=app.config.get("PORT", "8080") |
|
|
|
) |
|
|
|
|
|
|
|
# END |
|
|
|