Browse Source

Update WEB Interface v1.3

master
Evangelos Oulis 5 years ago
parent
commit
8e65e97896
  1. 27
      serverNode/serv.py
  2. 4
      webInterface/parking.html

27
serverNode/serv.py

@ -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

4
webInterface/parking.html

@ -82,9 +82,9 @@ $(document).ready(function(){
success: function(resultData) {
$.each(resultData, function(key, val) {
console.log("Parking No " + val.no + " -> " + val.status);
if (val.status == false)
if (val.status == true)
$("div#" + val.no).removeClass("full").addClass("empty");
else if (val.status == true)
else if (val.status == false)
$("div#" + val.no).removeClass("empty").addClass("full");
});
},

Loading…
Cancel
Save